err := apiServer.Start() Ω(err).ShouldNot(HaveOccurred()) Eventually(ErrorDialing("unix", socketPath)).ShouldNot(HaveOccurred()) }) It("stops accepting new connections", func() { go apiServer.Stop() Eventually(ErrorDialing("unix", socketPath)).Should(HaveOccurred()) }) It("stops the backend", func() { apiServer.Stop() Ω(fakeBackend.StopCallCount()).Should(Equal(1)) }) Context("when a Create request is in-flight", func() { var creating chan struct{} var finishCreating chan struct{} BeforeEach(func() { creating = make(chan struct{}) finishCreating = make(chan struct{}) fakeBackend.CreateStub = func(garden.ContainerSpec) (garden.Container, error) { close(creating) <-finishCreating return new(fakes.FakeContainer), nil }