github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/actor/v7pushaction/handle_stack_override_test.go (about)

     1  package v7pushaction_test
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/command/translatableerror"
     5  	"code.cloudfoundry.org/cli/util/manifestparser"
     6  
     7  	. "code.cloudfoundry.org/cli/actor/v7pushaction"
     8  
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("HandleStackOverride", func() {
    14  	var (
    15  		originalManifest    manifestparser.Manifest
    16  		transformedManifest manifestparser.Manifest
    17  		overrides           FlagOverrides
    18  		executeErr          error
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		originalManifest = manifestparser.Manifest{}
    23  		overrides = FlagOverrides{}
    24  	})
    25  
    26  	JustBeforeEach(func() {
    27  		transformedManifest, executeErr = HandleStackOverride(originalManifest, overrides)
    28  	})
    29  
    30  	When("stack flag is set", func() {
    31  		When("there is a single app in the manifest with a stack specified", func() {
    32  			BeforeEach(func() {
    33  				overrides.Stack = "cflinuxfs2"
    34  
    35  				originalManifest.Applications = []manifestparser.Application{
    36  					{
    37  						Stack: "cflinuxfs3",
    38  					},
    39  				}
    40  			})
    41  
    42  			It("will override the stack in the manifest with the provided flag value", func() {
    43  				Expect(executeErr).To(Not(HaveOccurred()))
    44  				Expect(transformedManifest.Applications).To(ConsistOf(
    45  					manifestparser.Application{
    46  						Stack: "cflinuxfs2",
    47  					},
    48  				))
    49  			})
    50  		})
    51  
    52  		When("there are multiple apps in the manifest", func() {
    53  			BeforeEach(func() {
    54  				overrides.Stack = "cflinuxfs2"
    55  
    56  				originalManifest.Applications = []manifestparser.Application{
    57  					{},
    58  					{},
    59  				}
    60  			})
    61  
    62  			It("returns an error", func() {
    63  				Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{}))
    64  			})
    65  		})
    66  	})
    67  })