func (expectation transitionExpectation) transitionToState(allocationStore *allocationstore.AllocationStore, container executor.Container) error {
	switch expectation.to {
	case "reserve":
		allocationRequest := executor.NewAllocationRequest(container.Guid, &container.Resource, container.Tags)
		_, err := allocationStore.Allocate(logger, &allocationRequest)
		return err

	case "initialize":
		runReq := executor.NewRunRequest(container.Guid, &container.RunInfo, container.Tags)
		return allocationStore.Initialize(logger, &runReq)

	case "fail":
		_, err := allocationStore.Fail(logger, container.Guid, "failure-reason")
		return err

	default:
		Fail("unknown 'to' state: " + expectation.to)
		return nil
	}
}
func (expectation transitionExpectation) driveFromState(allocationStore *allocationstore.AllocationStore, container executor.Container) {
	allocationRequest := executor.NewAllocationRequest(container.Guid, &container.Resource, container.Tags)
	runReq := executor.NewRunRequest(container.Guid, &container.RunInfo, container.Tags)

	switch expectation.from {
	case "non-existent":

	case "reserved":
		_, err := allocationStore.Allocate(logger, &allocationRequest)
		Expect(err).NotTo(HaveOccurred())

	case "initializing":
		_, err := allocationStore.Allocate(logger, &allocationRequest)
		Expect(err).NotTo(HaveOccurred())

		err = allocationStore.Initialize(logger, &runReq)
		Expect(err).NotTo(HaveOccurred())

	case "failed":
		_, err := allocationStore.Allocate(logger, &allocationRequest)
		Expect(err).NotTo(HaveOccurred())

		err = allocationStore.Initialize(logger, &runReq)
		Expect(err).NotTo(HaveOccurred())

		_, err = allocationStore.Fail(logger, container.Guid, "failure-reason")
		Expect(err).NotTo(HaveOccurred())

	default:
		Fail("unknown 'from' state: " + expectation.from)
	}
}
	"github.com/cloudfoundry-incubator/executor/depot/allocationstore/fakes"
	"github.com/pivotal-golang/clock/fakeclock"
	"github.com/pivotal-golang/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var logger = lagertest.NewTestLogger("test")

var _ = Describe("Allocation Store", func() {
	var (
		allocationStore  *allocationstore.AllocationStore
		fakeClock        *fakeclock.FakeClock
		fakeEventEmitter *fakes.FakeEventEmitter
		currentTime      time.Time
	)

	BeforeEach(func() {
		currentTime = time.Now()
		fakeClock = fakeclock.NewFakeClock(currentTime)
		fakeEventEmitter = &fakes.FakeEventEmitter{}
		allocationStore = allocationstore.NewAllocationStore(fakeClock, fakeEventEmitter)
	})

	Describe("List", func() {
		Context("when a container is allocated", func() {
			var req executor.AllocationRequest

			BeforeEach(func() {