github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/actor/v7pushaction/set_droplet_for_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  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("SetDropletForApplication", func() {
    14  	var (
    15  		actor       *Actor
    16  		fakeV7Actor *v7pushactionfakes.FakeV7Actor
    17  
    18  		paramPlan PushPlan
    19  
    20  		warnings   Warnings
    21  		executeErr error
    22  
    23  		events []Event
    24  	)
    25  
    26  	BeforeEach(func() {
    27  		actor, fakeV7Actor, _ = getTestPushActor()
    28  
    29  		paramPlan = PushPlan{
    30  			Application: v7action.Application{
    31  				GUID: "some-app-guid",
    32  			},
    33  			DropletGUID: "some-droplet-guid",
    34  		}
    35  	})
    36  
    37  	JustBeforeEach(func() {
    38  		events = EventFollower(func(eventStream chan<- *PushEvent) {
    39  			_, warnings, executeErr = actor.SetDropletForApplication(paramPlan, eventStream, nil)
    40  		})
    41  	})
    42  
    43  	When("setting the droplet is successful", func() {
    44  		BeforeEach(func() {
    45  			fakeV7Actor.SetApplicationDropletReturns(v7action.Warnings{"some-set-droplet-warning"}, nil)
    46  		})
    47  
    48  		It("returns a SetDropletComplete event and warnings", func() {
    49  			Expect(executeErr).ToNot(HaveOccurred())
    50  			Expect(warnings).To(ConsistOf("some-set-droplet-warning"))
    51  			Expect(events).To(ConsistOf(SettingDroplet, SetDropletComplete))
    52  
    53  			Expect(fakeV7Actor.SetApplicationDropletCallCount()).To(Equal(1))
    54  			appGUID, dropletGUID := fakeV7Actor.SetApplicationDropletArgsForCall(0)
    55  			Expect(appGUID).To(Equal("some-app-guid"))
    56  			Expect(dropletGUID).To(Equal("some-droplet-guid"))
    57  		})
    58  	})
    59  
    60  	When("setting the droplet errors", func() {
    61  		BeforeEach(func() {
    62  			fakeV7Actor.SetApplicationDropletReturns(v7action.Warnings{"some-set-droplet-warning"}, errors.New("the climate is arid"))
    63  		})
    64  
    65  		It("returns an error and warnings", func() {
    66  			Expect(executeErr).To(MatchError("the climate is arid"))
    67  			Expect(warnings).To(ConsistOf("some-set-droplet-warning"))
    68  			Expect(events).To(ConsistOf(SettingDroplet))
    69  		})
    70  	})
    71  })