Expect(err).ToNot(HaveOccurred()) Expect(fakeStage.PerformCalls[0]).To(Equal(&fakebiui.PerformCall{ Name: "Waiting for the agent on VM 'fake-vm-cid'", })) }) It("stops vm", func() { err := instance.Delete(pingTimeout, pingDelay, fakeStage) Expect(err).ToNot(HaveOccurred()) Expect(fakeVM.StopCalled).To(Equal(1)) }) It("unmounts vm disks", func() { firstDisk := fakebidisk.NewFakeDisk("fake-disk-1") secondDisk := fakebidisk.NewFakeDisk("fake-disk-2") fakeVM.ListDisksDisks = []bidisk.Disk{firstDisk, secondDisk} err := instance.Delete(pingTimeout, pingDelay, fakeStage) Expect(err).ToNot(HaveOccurred()) Expect(fakeVM.UnmountDiskInputs).To(Equal([]fakebivm.UnmountDiskInput{ {Disk: firstDisk}, {Disk: secondDisk}, })) Expect(fakeStage.PerformCalls[2:4]).To(Equal([]*fakebiui.PerformCall{ {Name: "Unmounting disk 'fake-disk-1'"}, {Name: "Unmounting disk 'fake-disk-2'"}, }))
fakeVMManager.CreateVM = fakeVM mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl) fakeVM.AgentClientReturn = mockAgentClient expectedInstance = NewInstance( "fake-job-name", 0, fakeVM, fakeVMManager, fakeSSHTunnelFactory, mockStateBuilder, logger, ) expectedDisk = fakebidisk.NewFakeDisk("fake-disk-cid") fakeVM.UpdateDisksDisks = []bidisk.Disk{expectedDisk} }) JustBeforeEach(func() { allowApplySpecToBeCreated() }) It("returns an Instance that wraps a newly created VM", func() { instance, _, err := manager.Create( "fake-job-name", 0, deploymentManifest, fakeCloudStemcell, registry, fakeStage,
}) It("returns error when checking fails", func() { fakeCloud.HasVMErr = errors.New("fake-has-vm-error") _, err := vm.Exists() Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-has-vm-error")) }) }) Describe("UpdateDisks", func() { var expectedDisks []bidisk.Disk BeforeEach(func() { fakeDisk := fakebidisk.NewFakeDisk("fake-disk-cid") expectedDisks = []bidisk.Disk{fakeDisk} fakeDiskDeployer.SetDeployBehavior(expectedDisks, nil) }) It("delegates to DiskDeployer.Deploy", func() { fakeStage := fakebiui.NewFakeStage() disks, err := vm.UpdateDisks(diskPool, fakeStage) Expect(err).NotTo(HaveOccurred()) Expect(disks).To(Equal(expectedDisks)) Expect(fakeDiskDeployer.DeployInputs).To(Equal([]fakebivm.DeployInput{ { DiskPool: diskPool, Cloud: fakeCloud,
fakeDiskManager *fakebidisk.FakeManager diskPool bideplmanifest.DiskPool cloud *fakebicloud.FakeCloud fakeStage *fakebiui.FakeStage fakeVM *fakebivm.FakeVM fakeDisk *fakebidisk.FakeDisk fakeDiskRepo *fakebiconfig.FakeDiskRepo ) BeforeEach(func() { cloud = fakebicloud.NewFakeCloud() fakeVM = fakebivm.NewFakeVM("fake-vm-cid") fakeDiskManagerFactory := fakebidisk.NewFakeManagerFactory() fakeDiskManager = fakebidisk.NewFakeManager() fakeDisk = fakebidisk.NewFakeDisk("fake-new-disk-cid") fakeDiskManager.CreateDisk = fakeDisk fakeDiskManagerFactory.NewManagerManager = fakeDiskManager logger := boshlog.NewLogger(boshlog.LevelNone) fakeStage = fakebiui.NewFakeStage() fakeDiskRepo = fakebiconfig.NewFakeDiskRepo() diskDeployer = NewDiskDeployer( fakeDiskManagerFactory, fakeDiskRepo, logger, ) fakeDiskManager.SetFindCurrentBehavior([]bidisk.Disk{}, nil) fakeVM.SetAttachDiskBehavior(fakeDisk, nil) newDiskRecord := biconfig.DiskRecord{