Expect(err).NotTo(HaveOccurred()) Expect(worker.DestroyCallCount()).To(Equal(1)) Expect(worker.DestroyArgsForCall(0)).To(Equal("created-handle")) }) }) Describe("a looked-up container", func() { It("calls through to garden", func() { fakeContainer := new(gfakes.FakeContainer) fakeContainer.HandleReturns("some-handle") worker.ContainersReturns([]garden.Container{fakeContainer}, nil) worker.LookupReturns(fakeContainer, nil) fakeDB.FindContainerByIdentifierReturns(db.Container{Handle: "some-handle"}, true, nil) container, found, err := workers[0].FindContainerForIdentifier(logger, Identifier{ Name: "some-name", }) Expect(err).NotTo(HaveOccurred()) Expect(found).To(BeTrue()) Expect(container.Handle()).To(Equal("some-handle")) err = container.Destroy() Expect(err).NotTo(HaveOccurred()) Expect(worker.DestroyCallCount()).To(Equal(1)) Expect(worker.DestroyArgsForCall(0)).To(Equal("some-handle")) })
}) Describe("a looked-up container", func() { It("calls through to garden", func() { fakeContainer := new(gfakes.FakeContainer) fakeContainer.HandleReturns("some-handle") worker.ContainersReturns([]garden.Container{fakeContainer}, nil) worker.LookupReturns(fakeContainer, nil) returnContainer := db.Container{ ContainerMetadata: db.ContainerMetadata{ Handle: "some-handle", }, } fakeDB.FindContainerByIdentifierReturns(returnContainer, true, nil) container, found, err := workers[0].FindContainerForIdentifier(logger, Identifier{ ResourceID: 1234, }) Expect(err).NotTo(HaveOccurred()) Expect(found).To(BeTrue()) Expect(container.Handle()).To(Equal("some-handle")) err = container.Destroy() Expect(err).NotTo(HaveOccurred()) Expect(worker.DestroyCallCount()).To(Equal(1)) Expect(worker.DestroyArgsForCall(0)).To(Equal("some-handle")) })