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