コード例 #1
0
		allocationStore = allocationstore.NewAllocationStore(fakeClock, fakeEventEmitter)
	})

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

			BeforeEach(func() {
				resource := executor.NewResource(512, 512, "")
				req = executor.NewAllocationRequest("banana", &resource, nil)
				_, err := allocationStore.Allocate(logger, &req)
				Expect(err).NotTo(HaveOccurred())
			})

			It("is included in the list", func() {
				allocations := allocationStore.List()
				Expect(allocations).To(HaveLen(1))
				Expect(allocations[0].Guid).To(Equal(req.Guid))
			})

			Context("and then deallocated", func() {
				BeforeEach(func() {
					deallocated := allocationStore.Deallocate(logger, req.Guid)
					Expect(deallocated).To(BeTrue())
				})

				It("is no longer in the list", func() {
					Expect(allocationStore.List()).To(BeEmpty())
				})
			})
		})