github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/handle_strategy_override_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 . "code.cloudfoundry.org/cli/actor/v7pushaction" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" 6 "code.cloudfoundry.org/cli/command/translatableerror" 7 "code.cloudfoundry.org/cli/util/manifestparser" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("HandleStrategyOverride", func() { 13 var ( 14 transformedManifest manifestparser.Manifest 15 executeErr error 16 17 parsedManifest manifestparser.Manifest 18 flagOverrides FlagOverrides 19 ) 20 21 JustBeforeEach(func() { 22 transformedManifest, executeErr = HandleStrategyOverride( 23 parsedManifest, 24 flagOverrides, 25 ) 26 }) 27 28 When("the strategy flag override is set", func() { 29 BeforeEach(func() { 30 flagOverrides = FlagOverrides{Strategy: constant.DeploymentStrategyRolling} 31 }) 32 33 When("there are multiple apps in the manifest", func() { 34 BeforeEach(func() { 35 parsedManifest = manifestparser.Manifest{ 36 Applications: []manifestparser.Application{ 37 {}, 38 {}, 39 }, 40 } 41 }) 42 43 It("returns an error", func() { 44 Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) 45 }) 46 }) 47 48 When("there is a single app in the manifest", func() { 49 BeforeEach(func() { 50 parsedManifest = manifestparser.Manifest{ 51 Applications: []manifestparser.Application{ 52 {}, 53 }, 54 } 55 }) 56 57 It("returns the unchanged manifest", func() { 58 Expect(executeErr).NotTo(HaveOccurred()) 59 Expect(transformedManifest.Applications).To(ConsistOf( 60 manifestparser.Application{}, 61 )) 62 }) 63 }) 64 }) 65 66 When("the strategy flag override is not set", func() { 67 BeforeEach(func() { 68 flagOverrides = FlagOverrides{} 69 }) 70 71 When("there are multiple apps in the manifest", func() { 72 BeforeEach(func() { 73 parsedManifest = manifestparser.Manifest{ 74 Applications: []manifestparser.Application{ 75 {}, 76 {}, 77 }, 78 } 79 }) 80 81 It("does not return an error", func() { 82 Expect(executeErr).NotTo(HaveOccurred()) 83 }) 84 }) 85 }) 86 })