github.com/sleungcy/cli@v7.1.0+incompatible/actor/v7pushaction/stop_application_test.go (about) 1 package v7pushaction_test 2 3 import ( 4 "errors" 5 6 "code.cloudfoundry.org/cli/actor/v7action" 7 . "code.cloudfoundry.org/cli/actor/v7pushaction" 8 "code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" 9 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" 10 "code.cloudfoundry.org/cli/resources" 11 . "github.com/onsi/ginkgo" 12 . "github.com/onsi/gomega" 13 ) 14 15 var _ = Describe("StopApplication", func() { 16 var ( 17 actor *Actor 18 fakeV7Actor *v7pushactionfakes.FakeV7Actor 19 20 paramPlan PushPlan 21 22 warnings Warnings 23 executeErr error 24 25 events []Event 26 ) 27 28 BeforeEach(func() { 29 actor, fakeV7Actor, _ = getTestPushActor() 30 31 paramPlan = PushPlan{ 32 Application: resources.Application{ 33 GUID: "some-app-guid", 34 }, 35 } 36 }) 37 38 JustBeforeEach(func() { 39 events = EventFollower(func(eventStream chan<- *PushEvent) { 40 _, warnings, executeErr = actor.StopApplication(paramPlan, eventStream, nil) 41 }) 42 }) 43 44 When("The app is running", func() { 45 BeforeEach(func() { 46 fakeV7Actor.StopApplicationReturns(v7action.Warnings{"some-stopping-warning"}, nil) 47 paramPlan.Application.State = constant.ApplicationStarted 48 }) 49 50 When("Stopping the app succeeds", func() { 51 It("Uploads a package and exits", func() { 52 Expect(executeErr).ToNot(HaveOccurred()) 53 Expect(warnings).To(ConsistOf("some-stopping-warning")) 54 Expect(events).To(ConsistOf(StoppingApplication, StoppingApplicationComplete)) 55 56 Expect(fakeV7Actor.StopApplicationCallCount()).To(Equal(1)) 57 Expect(fakeV7Actor.StopApplicationArgsForCall(0)).To(Equal("some-app-guid")) 58 Expect(fakeV7Actor.StageApplicationPackageCallCount()).To(BeZero()) 59 }) 60 }) 61 62 When("Stopping the app fails", func() { 63 BeforeEach(func() { 64 fakeV7Actor.StopApplicationReturns(v7action.Warnings{"some-stopping-warning"}, errors.New("bummer")) 65 }) 66 67 It("returns errors and warnings", func() { 68 Expect(executeErr).To(MatchError("bummer")) 69 Expect(warnings).To(ConsistOf("some-stopping-warning")) 70 Expect(events).To(ConsistOf(StoppingApplication)) 71 }) 72 }) 73 }) 74 })