github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/actor/v7pushaction/handle_stack_override_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 "github.com/LukasHeimann/cloudfoundrycli/v8/command/translatableerror" 5 "github.com/LukasHeimann/cloudfoundrycli/v8/util/manifestparser" 6 7 . "github.com/LukasHeimann/cloudfoundrycli/v8/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 is not set", func() { 31 When("there is a single app in the manifest with the stack specified", func() { 32 BeforeEach(func() { 33 originalManifest.Applications = []manifestparser.Application{ 34 { 35 Stack: "og_cflinuxfs", 36 }, 37 } 38 }) 39 40 It("will retain the origional stack value", func() { 41 Expect(executeErr).To(Not(HaveOccurred())) 42 Expect(transformedManifest.Applications[0].Stack).To(Equal("og_cflinuxfs")) 43 }) 44 }) 45 }) 46 47 When("stack flag is set", func() { 48 When("there is a single app in the manifest with a stack specified", func() { 49 BeforeEach(func() { 50 overrides.Stack = "cflinuxfs2" 51 52 originalManifest.Applications = []manifestparser.Application{ 53 { 54 Stack: "cflinuxfs3", 55 }, 56 } 57 }) 58 59 It("will override the stack in the manifest with the provided flag value", func() { 60 Expect(executeErr).To(Not(HaveOccurred())) 61 Expect(transformedManifest.Applications).To(ConsistOf( 62 manifestparser.Application{ 63 Stack: "cflinuxfs2", 64 }, 65 )) 66 }) 67 }) 68 69 When("there are multiple apps in the manifest", func() { 70 BeforeEach(func() { 71 overrides.Stack = "cflinuxfs2" 72 73 originalManifest.Applications = []manifestparser.Application{ 74 {}, 75 {}, 76 } 77 }) 78 79 It("returns an error", func() { 80 Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) 81 }) 82 }) 83 }) 84 })