response := models.EvacuationResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes()) Expect(err).NotTo(HaveOccurred()) Expect(response.KeepContainer).To(BeFalse()) Expect(response.Error).To(BeNil()) Expect(fakeEvacuationDB.RemoveEvacuatingActualLRPCallCount()).To(Equal(1)) _, key, instanceKey := fakeEvacuationDB.RemoveEvacuatingActualLRPArgsForCall(0) Expect(*key).To(Equal(actual.ActualLRPKey)) Expect(*instanceKey).To(Equal(actual.ActualLRPInstanceKey)) }) It("emits events to the hub", func() { Eventually(actualHub.EmitCallCount).Should(Equal(2)) for i := 0; i < actualHub.EmitCallCount(); i++ { switch event := actualHub.EmitArgsForCall(i).(type) { case *models.ActualLRPRemovedEvent: Expect(event.ActualLrpGroup).To(Equal(&models.ActualLRPGroup{Evacuating: actual})) case *models.ActualLRPChangedEvent: Expect(event.Before).To(Equal(&models.ActualLRPGroup{Instance: actual})) Expect(event.After).To(Equal(&models.ActualLRPGroup{Instance: afterActual})) default: Fail(fmt.Sprintf("unexpected event %#v", event)) } } }) It("unclaims the actual lrp instance and requests an auction", func() { response := models.EvacuationResponse{} err := response.Unmarshal(responseRecorder.Body.Bytes())
Action: models.WrapAction(&models.RunAction{ User: "******", Path: "ls", }), Domain: "tests", ProcessGuid: expectedProcessGuid, } }) Context("when a create arrives", func() { BeforeEach(func() { desiredCreateCB(desiredLRP) }) It("emits a DesiredLRPCreatedEvent to the hub", func() { Expect(hub.EmitCallCount()).To(Equal(1)) event := hub.EmitArgsForCall(0) desiredLRPCreatedEvent, ok := event.(*models.DesiredLRPCreatedEvent) Expect(ok).To(BeTrue()) Expect(desiredLRPCreatedEvent.DesiredLrp).To(Equal(desiredLRP)) }) }) Context("when a change arrives", func() { BeforeEach(func() { desiredChangeCB(&models.DesiredLRPChange{Before: desiredLRP, After: desiredLRP}) }) It("emits a DesiredLRPChangedEvent to the hub", func() { Expect(hub.EmitCallCount()).To(Equal(1))