Expect(fakeRepClient.StopLRPInstanceCallCount()).To(Equal(2)) key, instanceKey := fakeRepClient.StopLRPInstanceArgsForCall(0) Expect(key).To(Equal(runningActualLRPGroup.Instance.ActualLRPKey)) Expect(instanceKey).To(Equal(runningActualLRPGroup.Instance.ActualLRPInstanceKey)) key, instanceKey = fakeRepClient.StopLRPInstanceArgsForCall(1) Expect(key).To(Equal(evacuatingAndRunningActualLRPGroup.Instance.ActualLRPKey)) Expect(instanceKey).To(Equal(evacuatingAndRunningActualLRPGroup.Instance.ActualLRPInstanceKey)) }) It("removes all of the corresponding unclaimed and crashed actual lrps", func() { Expect(fakeActualLRPDB.ActualLRPGroupsByProcessGuidCallCount()).To(Equal(1)) _, processGuid := fakeActualLRPDB.ActualLRPGroupsByProcessGuidArgsForCall(0) Expect(processGuid).To(Equal("some-guid")) Expect(fakeActualLRPDB.RemoveActualLRPCallCount()).To(Equal(2)) _, processGuid, index, actualLRPInstanceKey := fakeActualLRPDB.RemoveActualLRPArgsForCall(0) Expect(index).To(BeEquivalentTo(3)) Expect(processGuid).To(Equal("some-guid")) Expect(actualLRPInstanceKey).To(BeNil()) _, processGuid, index, actualLRPInstanceKey = fakeActualLRPDB.RemoveActualLRPArgsForCall(1) Expect(index).To(BeEquivalentTo(4)) Expect(processGuid).To(Equal("some-guid")) Expect(actualLRPInstanceKey).To(BeNil()) }) Context("when fetching the actual lrps fails", func() { BeforeEach(func() { fakeActualLRPDB.ActualLRPGroupsByProcessGuidReturns(nil, errors.New("new error dawg"))