func (p *FakeContainerPool) Create(spec backend.ContainerSpec) (linux_backend.Container, error) {
	if p.CreateError != nil {
		return nil, p.CreateError
	}

	container := fake_backend.NewFakeContainer(spec)

	if p.ContainerSetup != nil {
		p.ContainerSetup(container)
	}

	p.CreatedContainers = append(p.CreatedContainers, container)

	return container, nil
}
func (p *FakeContainerPool) Restore(snapshot io.Reader) (linux_backend.Container, error) {
	if p.RestoreError != nil {
		return nil, p.RestoreError
	}

	var handle string

	_, err := fmt.Fscanf(snapshot, "%s", &handle)
	if err != nil && err != io.EOF {
		return nil, err
	}

	container := fake_backend.NewFakeContainer(
		backend.ContainerSpec{
			Handle: handle,
		},
	)

	p.RestoredSnapshots = append(p.RestoredSnapshots, snapshot)

	return container, nil
}
	"github.com/pivotal-cf-experimental/garden/backend/fake_backend"
	"github.com/pivotal-cf-experimental/garden/server/bomberman"
	"time"
)

var _ = Describe("Bomberman", func() {
	It("straps a bomb to the given container with the container's grace time as the countdown", func() {
		detonated := make(chan backend.Container)

		bomberman := bomberman.New(func(container backend.Container) {
			detonated <- container
		})

		container := fake_backend.NewFakeContainer(
			backend.ContainerSpec{
				GraceTime: 100 * time.Millisecond,
				Handle:    "doomed",
			},
		)

		bomberman.Strap(container)

		select {
		case <-detonated:
		case <-time.After(container.GraceTime() + 50*time.Millisecond):
			Fail("did not detonate!")
		}
	})

	Context("when the container has a grace time of 0", func() {
		It("never detonates", func() {
			detonated := make(chan backend.Container)