var newlyDesiredLRP *models.DesiredLRP

		BeforeEach(func() {
			newlyDesiredLRP = &models.DesiredLRP{
				ProcessGuid: "new-process-guid",
				Instances:   1,
				RootFs:      models.PreloadedRootFS("stack-2"),
				Action: models.WrapAction(&models.RunAction{
					User: "******",
					Path: "ls",
				}),
				Annotation: "last-modified-etag",
			}

			fakeBBS.DesiredLRPByProcessGuidReturns(&models.DesiredLRP{}, models.ErrResourceNotFound)
			buildpackBuilder.BuildReturns(newlyDesiredLRP, nil)
		})

		It("logs the incoming and outgoing request", func() {
			Eventually(logger.TestSink.Buffer).Should(gbytes.Say("request-from-cc"))
			Eventually(logger.TestSink.Buffer).Should(gbytes.Say("creating-desired-lrp"))
		})

		It("creates the desired LRP", func() {
			Expect(fakeBBS.DesireLRPCallCount()).To(Equal(1))

			Expect(fakeBBS.DesiredLRPByProcessGuidCallCount()).To(Equal(1))
			Expect(fakeBBS.DesireLRPArgsForCall(0)).To(Equal(newlyDesiredLRP))

			Expect(buildpackBuilder.BuildArgsForCall(0)).To(Equal(&desireAppRequest))
		})
Example #2
0
				Context("and the differ provides creates, updates, and deletes", func() {
					It("sends the deletes but not the creates or updates", func() {
						Consistently(bbsClient.DesireLRPCallCount).Should(Equal(0))
						Consistently(bbsClient.UpdateDesiredLRPCallCount).Should(Equal(0))

						Eventually(bbsClient.RemoveDesiredLRPCallCount).Should(Equal(1))
						Consistently(bbsClient.RemoveDesiredLRPCallCount).Should(Equal(1))
						Expect(bbsClient.RemoveDesiredLRPArgsForCall(0)).To(Equal("excess-process-guid"))
					})
				})
			})

			Context("when building the desire LRP request fails", func() {
				BeforeEach(func() {
					buildpackRecipeBuilder.BuildReturns(nil, errors.New("nope"))
				})

				It("keeps calm and carries on", func() {
					Consistently(process.Wait()).ShouldNot(Receive())
				})

				It("does not update the domain", func() {
					Consistently(bbsClient.UpsertDomainCallCount).Should(Equal(0))
				})

				Context("and the differ provides creates, updates, and deletes", func() {
					It("continues to send the deletes and updates", func() {
						Eventually(bbsClient.RemoveDesiredLRPCallCount).Should(Equal(1))
						Consistently(bbsClient.RemoveDesiredLRPCallCount).Should(Equal(1))
						Expect(bbsClient.RemoveDesiredLRPArgsForCall(0)).To(Equal("excess-process-guid"))