Expect(err).ToNot(HaveOccurred()) }) It("clears current stemcell in the repo", func() { err := cloudStemcell.Delete() Expect(err).ToNot(HaveOccurred()) _, found, err := stemcellRepo.FindCurrent() Expect(err).ToNot(HaveOccurred()) Expect(found).To(BeFalse()) }) }) Context("when deleting stemcell in the cloud fails", func() { BeforeEach(func() { fakeCloud.DeleteStemcellErr = errors.New("fake-delete-stemcell-error") }) It("returns an error", func() { err := cloudStemcell.Delete() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-delete-stemcell-error")) }) }) Context("when deleting stemcell in the cloud fails with StemcellNotFoundError", func() { var deleteErr = bicloud.NewCPIError("delete_stemcell", bicloud.CmdError{ Type: bicloud.StemcellNotFoundError, Message: "fake-stemcell-not-found-message", })