expectedRunRequest, err := rep.NewRunRequestFromDesiredLRP(container.Guid, desiredLRP, &expectedLrpKey, &expectedInstanceKey)
						Expect(err).NotTo(HaveOccurred())

						delegateLogger, runRequest := containerDelegate.RunContainerArgsForCall(0)
						Expect(*runRequest).To(Equal(expectedRunRequest))
						Expect(delegateLogger.SessionName()).To(Equal(expectedSessionName))
					})

					Context("when running fails", func() {
						BeforeEach(func() {
							containerDelegate.RunContainerReturns(false)
						})

						It("removes the actual LRP", func() {
							Expect(bbsClient.RemoveActualLRPCallCount()).To(Equal(1))
							processGuid, index := bbsClient.RemoveActualLRPArgsForCall(0)

							Expect(processGuid).To(Equal(expectedLrpKey.ProcessGuid))
							Expect(int32(index)).To(Equal(expectedLrpKey.Index))
						})
					})
				})

				var itClaimsTheLRPOrDeletesTheContainer = func(expectedSessionName string) {
					It("claims the lrp", func() {
						Expect(bbsClient.ClaimActualLRPCallCount()).To(Equal(1))
						processGuid, index, instanceKey := bbsClient.ClaimActualLRPArgsForCall(0)
						Expect(processGuid).To(Equal(expectedLrpKey.ProcessGuid))
						Expect(int32(index)).To(Equal(expectedLrpKey.Index))
						Expect(*instanceKey).To(Equal(expectedInstanceKey))
					})