It("checks whether the container exists", func() { Expect(containerDelegate.GetContainerCallCount()).To(Equal(1)) containerDelegateLogger, containerGuid := containerDelegate.GetContainerArgsForCall(0) Expect(containerGuid).To(Equal(expectedContainerGuid)) Expect(containerDelegateLogger.SessionName()).To(Equal(sessionName)) }) It("logs its execution lifecycle", func() { Expect(logger).To(Say(sessionName + ".starting")) Expect(logger).To(Say(sessionName + ".finished")) }) Context("when the container does not exist", func() { BeforeEach(func() { containerDelegate.GetContainerReturns(executor.Container{}, false) }) It("removes the actualLRP", func() { Expect(fakeBBS.RemoveActualLRPCallCount()).To(Equal(1)) processGuid, index := fakeBBS.RemoveActualLRPArgsForCall(0) Expect(processGuid).To(Equal(lrpKey.ProcessGuid)) Expect(index).To(Equal(int(lrpKey.Index))) }) }) Context("when the container exists", func() { BeforeEach(func() { containerDelegate.GetContainerReturns(executor.Container{}, true) })