}) Context("when instance exists", func() { It("returns true", func() { instanceID := "foo" result, err := repo.InstanceExists(instanceID) Ω(result).Should(BeTrue()) Ω(err).ShouldNot(HaveOccurred()) }) }) }) Describe("#Destroy", func() { Context("when deleting an existing instance", func() { It("deallocates the instance", func() { err := repo.Destroy("foo") Expect(err).ToNot(HaveOccurred()) Expect(len(repo.AvailableInstances())).To(Equal(3)) }) It("writes the new state to the statefile", func() { err := repo.Destroy("foo") Expect(err).ToNot(HaveOccurred()) statefileContents := getStatefileContents(statefilePath) Expect(len(statefileContents.AllocatedInstances)).To(Equal(0)) }) It("resets the instance data", func() { instance, err := repo.FindByID("foo") Expect(err).ToNot(HaveOccurred())