github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/command/flag/binding_name_test.go (about)

     1  package flag_test
     2  
     3  import (
     4  	. "code.cloudfoundry.org/cli/command/flag"
     5  	flags "github.com/jessevdk/go-flags"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  )
     9  
    10  var _ = Describe("BindingName", func() {
    11  	var bindingName BindingName
    12  
    13  	BeforeEach(func() {
    14  		bindingName = BindingName{}
    15  	})
    16  
    17  	When("the value provided to the --binding-name flag is the empty string", func() {
    18  		It("returns a ErrMarshal error that the binding name must be greater than 1 character long", func() {
    19  			Expect(bindingName.UnmarshalFlag("")).To(MatchError(&flags.Error{
    20  				Type:    flags.ErrMarshal,
    21  				Message: "--binding-name must be at least 1 character in length",
    22  			}))
    23  		})
    24  	})
    25  
    26  	When("the value provided to the --binding-name flag is greater than 0 characters long", func() {
    27  		It("stores the binding name and does not return an error", func() {
    28  			bindingName.UnmarshalFlag("some-name")
    29  			Expect(bindingName.Value).To(Equal("some-name"))
    30  		})
    31  	})
    32  })