コード例 #1
0
		Context("when running fails", func() {
			BeforeEach(func() {
				executorClient.RunContainerReturns(errors.New("ka-boom"))
			})

			It("returns false", func() {
				Expect(result).To(BeFalse())
			})

			It("logs the failure", func() {
				Expect(logger).To(gbytes.Say(sessionPrefix + ".failed-running-container"))
			})

			It("deletes the container", func() {
				Expect(executorClient.DeleteContainerCallCount()).To(Equal(1))
				_, containerGuid := executorClient.DeleteContainerArgsForCall(0)
				Expect(containerGuid).To(Equal(expectedGuid))
			})

			It("logs the deletion", func() {
				Expect(logger).To(gbytes.Say(sessionPrefix + ".deleting-container"))
				Expect(logger).To(gbytes.Say(sessionPrefix + ".succeeded-deleting-container"))
			})

			Context("when deleting fails", func() {
				BeforeEach(func() {
					executorClient.DeleteContainerReturns(errors.New("boom"))
				})

				It("logs the failure", func() {
					Expect(logger).To(gbytes.Say(sessionPrefix + ".failed-deleting-container"))