Пример #1
0
			})
		})

		Context("orphan stemcell records exist", func() {
			BeforeEach(func() {
				_, err := stemcellRepo.Save("orphan-stemcell-name", "orphan-stemcell-version", "orphan-stemcell-cid")
				Expect(err).ToNot(HaveOccurred())
			})

			It("deletes the unused stemcells", func() {
				mockCloud.EXPECT().DeleteStemcell("orphan-stemcell-cid")

				err := deploymentManager.Cleanup(fakeStage)
				Expect(err).ToNot(HaveOccurred())

				stemcellRecords, err := stemcellRepo.All()
				Expect(err).ToNot(HaveOccurred())
				Expect(stemcellRecords).To(BeEmpty(), "expected no stemcell records")
			})

			It("logs delete stage", func() {
				mockCloud.EXPECT().DeleteStemcell("orphan-stemcell-cid")

				err := deploymentManager.Cleanup(fakeStage)
				Expect(err).ToNot(HaveOccurred())

				Expect(fakeStage.PerformCalls).To(ContainElement(&fakebiui.PerformCall{
					Name: "Deleting unused stemcell 'orphan-stemcell-cid'",
				}))
			})