github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/command/flag/tags_test.go (about) 1 package flag_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/command/flag" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("Tags", func() { 10 var tags Tags 11 12 BeforeEach(func() { 13 tags = Tags{} 14 }) 15 16 Describe("UnmarshalFlag", func() { 17 When("the empty string is provided", func() { 18 It("should return empty list", func() { 19 Expect(tags.UnmarshalFlag("")).To(Succeed()) 20 Expect(tags).To(ConsistOf([]string{})) 21 }) 22 }) 23 24 When("single tag is provided", func() { 25 It("should return the string", func() { 26 Expect(tags.UnmarshalFlag("tag")).To(Succeed()) 27 Expect(tags).To(ConsistOf([]string{"tag"})) 28 }) 29 }) 30 31 When("multiple comma separated tags are provided", func() { 32 It("should return the string", func() { 33 Expect(tags.UnmarshalFlag("tag1,tag2")).To(Succeed()) 34 Expect(tags).To(ConsistOf([]string{"tag1", "tag2"})) 35 }) 36 }) 37 38 When("multiple tags with spaces are provided", func() { 39 It("should return the trimmed tags", func() { 40 Expect(tags.UnmarshalFlag(" tag1, tag2")).To(Succeed()) 41 Expect(tags).To(ConsistOf([]string{"tag1", "tag2"})) 42 }) 43 }) 44 45 When("multiple tags with excessive commas are provided", func() { 46 It("should return just the tags", func() { 47 Expect(tags.UnmarshalFlag(",tag1,tag2,")).To(Succeed()) 48 Expect(tags).To(ConsistOf([]string{"tag1", "tag2"})) 49 }) 50 }) 51 }) 52 })