Пример #1
0
		fakeCake.RemoveStub = func(id layercake.ID) error {
			delete(child2parent, id)
			return nil
		}
	})

	Describe("Remove", func() {
		Context("when the layer has no parents", func() {
			BeforeEach(func() {
				fakeCake.GetReturns(&image.Image{}, nil)
			})

			It("removes the layer", func() {
				Expect(gc.Remove(layercake.ContainerID("child"))).To(Succeed())
				Expect(fakeCake.RemoveCallCount()).To(Equal(1))
				Expect(fakeCake.RemoveArgsForCall(0)).To(Equal(layercake.ContainerID("child")))
			})

			Context("when the layer is retained", func() {
				BeforeEach(func() {
					fakeRetainer.IsHeldReturns(true)
				})

				It("should not remove the layer", func() {
					Expect(gc.Remove(layercake.ContainerID("child"))).To(Succeed())
					Expect(fakeCake.RemoveCallCount()).To(Equal(0))
				})
			})
		})