})

	Context("when the allocator returns an error", func() {
		It("aborts and returns the error without wrapping it", func() {
			allocateError := errors.New("some, possibly typed error")
			ipAllocator.AllocateIPReturns(nil, allocateError)
			_, err := controller.Add(payload)

			Expect(err).To(BeIdenticalTo(allocateError))
		})
	})

	Context("when container creation fails", func() {
		It("aborts and returns a wrapped error", func() {
			creator.SetupReturns(models.Container{}, errors.New("some error"))
			_, err := controller.Add(payload)

			Expect(datastore.CreateCallCount()).To(BeZero())
			Expect(err).To(MatchError("container setup: some error"))
		})
	})

	Context("when datastore create fails", func() {
		It("returns a wrapped error", func() {
			datastore.CreateReturns(errors.New("some error"))
			_, err := controller.Add(payload)
			Expect(err).To(MatchError("datastore create: some error"))
		})
	})
})