github.com/sap/cf-mta-plugin@v2.6.3+incompatible/util/cf_command_options_util_test.go (about) 1 package util_test 2 3 import ( 4 . "github.com/cloudfoundry-incubator/multiapps-cli-plugin/util" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("CfCommandOptionsUtil", func() { 11 Describe("DiscardIfEmpty", func() { 12 Context("with regular string value", func() { 13 It("should return the value as is", func() { 14 value := "some value" 15 Expect(DiscardIfEmpty(value)).To(Equal(&value)) 16 }) 17 }) 18 Context("with string value with only whitespace", func() { 19 It("should return the value as is", func() { 20 value := " " 21 Expect(DiscardIfEmpty(value)).To(Equal(&value)) 22 }) 23 }) 24 Context("with empty string value", func() { 25 It("should return nil", func() { 26 Expect(TrimAndDiscardIfEmpty("")).To(BeNil()) 27 }) 28 }) 29 }) 30 Describe("TrimAndDiscardIfEmpty", func() { 31 expected_value := "some value" 32 33 Context("with regular string value", func() { 34 It("should return the value as is", func() { 35 Expect(TrimAndDiscardIfEmpty("some value")).To(Equal(&expected_value)) 36 }) 37 }) 38 Context("with string value with leading and trailing whitespace", func() { 39 It("should trim the value", func() { 40 Expect(TrimAndDiscardIfEmpty(" some value ")).To(Equal(&expected_value)) 41 }) 42 }) 43 Context("with empty string value", func() { 44 It("should return nil", func() { 45 Expect(TrimAndDiscardIfEmpty("")).To(BeNil()) 46 }) 47 }) 48 Context("with only whitespace in value", func() { 49 It("should return nil", func() { 50 Expect(TrimAndDiscardIfEmpty(" ")).To(BeNil()) 51 }) 52 }) 53 }) 54 })