}) It("emits a create event to the hub", func(done Done) { Eventually(desiredHub.EmitCallCount).Should(Equal(1)) event := desiredHub.EmitArgsForCall(0) changeEvent, ok := event.(*models.DesiredLRPChangedEvent) Expect(ok).To(BeTrue()) Expect(changeEvent.Before).To(Equal(beforeDesiredLRP)) Expect(changeEvent.After).To(Equal(afterDesiredLRP)) close(done) }) Context("when the number of instances changes", func() { BeforeEach(func() { instances := int32(3) update.Instances = &instances desiredLRP := &models.DesiredLRP{ ProcessGuid: "some-guid", Domain: "some-domain", RootFs: "some-stack", PlacementTags: []string{"taggggg"}, MemoryMb: 128, DiskMb: 512, Instances: 3, } fakeDesiredLRPDB.DesiredLRPByProcessGuidReturns(desiredLRP, nil) fakeServiceClient.CellByIdReturns(&models.CellPresence{ RepAddress: "some-address", RepUrl: "http://some-address",
}, } desiredLRP.LegacyDownloadUser = "******" assertDesiredLRPValidationFailsWithMessage(desiredLRP, "value") }) }) }) }) var _ = Describe("DesiredLRPUpdate", func() { var desiredLRPUpdate models.DesiredLRPUpdate BeforeEach(func() { two := int32(2) someText := "some-text" desiredLRPUpdate.Instances = &two desiredLRPUpdate.Annotation = &someText }) Describe("Validate", func() { var assertDesiredLRPValidationFailsWithMessage = func(lrp models.DesiredLRPUpdate, substring string) { validationErr := lrp.Validate() Expect(validationErr).To(HaveOccurred()) Expect(validationErr.Error()).To(ContainSubstring(substring)) } It("requires a positive nonzero number of instances", func() { minusOne := int32(-1) desiredLRPUpdate.Instances = &minusOne assertDesiredLRPValidationFailsWithMessage(desiredLRPUpdate, "instances")