github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/actor/v7pushaction/sequence_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/v7action" 5 . "code.cloudfoundry.org/cli/actor/v7pushaction" 6 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" 7 "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" 8 "code.cloudfoundry.org/cli/resources" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Actor", func() { 14 var ( 15 actor *Actor 16 plan PushPlan 17 sequence []ChangeApplicationFunc 18 ) 19 20 BeforeEach(func() { 21 actor, _, _ = getTestPushActor() 22 }) 23 24 Describe("GetPrepareApplicationSourceSequence", func() { 25 JustBeforeEach(func() { 26 sequence = actor.GetPrepareApplicationSourceSequence(plan) 27 }) 28 29 When("the plan requires creating a bits package", func() { 30 BeforeEach(func() { 31 plan = PushPlan{} 32 }) 33 34 It("returns a sequence including creating a bits package", func() { 35 Expect(sequence).To(matchers.MatchFuncsByName(actor.CreateBitsPackageForApplication)) 36 }) 37 }) 38 39 When("the plan requires creating a docker package", func() { 40 BeforeEach(func() { 41 plan = PushPlan{ 42 DockerImageCredentials: v7action.DockerImageCredentials{Path: "not empty"}, 43 } 44 }) 45 46 It("returns a sequence including creating a docker package", func() { 47 Expect(sequence).To(matchers.MatchFuncsByName(actor.CreateDockerPackageForApplication)) 48 }) 49 }) 50 51 When("the plan requires uploading a droplet", func() { 52 BeforeEach(func() { 53 plan = PushPlan{ 54 DropletPath: "path", 55 } 56 }) 57 58 It("returns a sequence including creating a droplet", func() { 59 Expect(sequence).To(matchers.MatchFuncsByName(actor.CreateDropletForApplication)) 60 }) 61 }) 62 }) 63 64 Describe("GetRuntimeSequence", func() { 65 JustBeforeEach(func() { 66 sequence = actor.GetRuntimeSequence(plan) 67 }) 68 69 When("the plan requires staging a package", func() { 70 BeforeEach(func() { 71 plan = PushPlan{} 72 }) 73 74 It("returns a sequence including staging, setting the droplet, and restarting", func() { 75 Expect(sequence).To(matchers.MatchFuncsByName(actor.StagePackageForApplication, actor.SetDropletForApplication, actor.RestartApplication)) 76 }) 77 }) 78 79 When("the plan requires stopping an app", func() { 80 BeforeEach(func() { 81 plan = PushPlan{ 82 NoStart: true, 83 Application: resources.Application{State: constant.ApplicationStarted}, 84 } 85 }) 86 87 It("returns a sequence including stopping the application", func() { 88 Expect(sequence).To(matchers.MatchFuncsByName(actor.StopApplication)) 89 }) 90 }) 91 92 When("the plan requires setting a droplet", func() { 93 BeforeEach(func() { 94 plan = PushPlan{ 95 DropletPath: "path", 96 } 97 }) 98 99 It("returns a sequence including setting the droplet and restarting", func() { 100 Expect(sequence).To(matchers.MatchFuncsByName(actor.SetDropletForApplication, actor.RestartApplication)) 101 }) 102 }) 103 104 When("the plan has strategy 'rolling'", func() { 105 BeforeEach(func() { 106 plan = PushPlan{ 107 Strategy: constant.DeploymentStrategyRolling, 108 } 109 }) 110 111 It("returns a sequence that creates a deployment without stopping/restarting the app", func() { 112 Expect(sequence).To(matchers.MatchFuncsByName(actor.StagePackageForApplication, actor.CreateDeploymentForApplication)) 113 }) 114 }) 115 116 When("the plan has task application type", func() { 117 BeforeEach(func() { 118 plan = PushPlan{ 119 TaskTypeApplication: true, 120 } 121 }) 122 123 It("returns a sequence that stages, sets droplet, and stops the app", func() { 124 Expect(sequence).To(matchers.MatchFuncsByName(actor.StagePackageForApplication, actor.StopApplication, actor.SetDropletForApplication)) 125 }) 126 }) 127 }) 128 })