github.com/sap/cf-mta-plugin@v2.6.3+incompatible/util/cf_command_builder_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("CfCommandBuilder", func() {
    11  	Describe("Build", func() {
    12  		Context("with valid argument and options", func() {
    13  			It("should return a valid command", func() {
    14  				commandBuilder := NewCfCommandStringBuilder()
    15  				commandBuilder.SetName("deploy")
    16  				commandBuilder.AddArgument("jobscheduler.mtar")
    17  				commandBuilder.AddBooleanOption("f")
    18  				commandBuilder.AddOption("t", "100")
    19  				commandBuilder.AddLongBooleanOption("no-start")
    20  				commandBuilder.AddOption("p", "XSA")
    21  				commandBuilder.AddLongOption("schema-version", "3")
    22  				Expect(commandBuilder.Build()).To(Equal("cf deploy jobscheduler.mtar -f -t 100 --no-start -p XSA --schema-version 3"))
    23  			})
    24  		})
    25  		Context("with just options and no arguments", func() {
    26  			It("should return a valid command", func() {
    27  				commandBuilder := NewCfCommandStringBuilder()
    28  				commandBuilder.SetName("deploy")
    29  				commandBuilder.AddOption("i", "12345")
    30  				commandBuilder.AddOption("a", "abort")
    31  				Expect(commandBuilder.Build()).To(Equal("cf deploy -i 12345 -a abort"))
    32  			})
    33  		})
    34  		Context("with just arguments and no options", func() {
    35  			It("should return a valid command", func() {
    36  				commandBuilder := NewCfCommandStringBuilder()
    37  				commandBuilder.SetName("deploy")
    38  				commandBuilder.AddArgument("jobscheduler1.mtar")
    39  				commandBuilder.AddArgument("jobscheduler2.mtar")
    40  				Expect(commandBuilder.Build()).To(Equal("cf deploy jobscheduler1.mtar jobscheduler2.mtar"))
    41  			})
    42  		})
    43  	})
    44  })