github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/command/flag/droplet_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("Droplet", func() {
    10  	var droplet Droplet
    11  
    12  	Describe("UnmarshalFlag", func() {
    13  		BeforeEach(func() {
    14  			droplet = Droplet{}
    15  		})
    16  
    17  		When("passed a path beginning with a slash", func() {
    18  			It("sets the path", func() {
    19  				err := droplet.UnmarshalFlag("/banana")
    20  				Expect(err).ToNot(HaveOccurred())
    21  				Expect(droplet.Path).To(Equal("/banana"))
    22  			})
    23  		})
    24  
    25  		When("passed a path that doesn't begin with a slash", func() {
    26  			It("prepends the path with a slash and sets it", func() {
    27  				err := droplet.UnmarshalFlag("banana")
    28  				Expect(err).ToNot(HaveOccurred())
    29  				Expect(droplet.Path).To(Equal("/banana"))
    30  			})
    31  		})
    32  	})
    33  })