예제 #1
0
	BeforeEach(func() {
		vmFinder = &fakevm.FakeFinder{}
		action = NewRebootVM(vmFinder)
	})

	Describe("Run", func() {
		It("tries to find vm with given vm cid", func() {
			_, err := action.Run(1234)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when vm is found with given vm cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("reboots vm", func() {
				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())

				Expect(vm.RebootCalled).To(BeTrue())
			})
		It("tries to find VM with given VM cid", func() {
			vmFinder.FindFound = true
			vmFinder.FindVM = fakevm.NewFakeVM(1234)

			diskFinder.FindFound = true
			diskFinder.FindDisk = fakedisk.NewFakeDisk(1234)

			_, err := action.Run(1234, 1234)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when VM is found with given VM cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("tries to find disk with given disk cid", func() {
				diskFinder.FindFound = true

				_, err := action.Run(1234, 1234)
				Expect(err).ToNot(HaveOccurred())

				Expect(diskFinder.FindID).To(Equal(1234))
예제 #3
0
	BeforeEach(func() {
		vmFinder = &fakevm.FakeFinder{}
		action = NewDeleteVM(vmFinder)
	})

	Describe("Run", func() {
		It("tries to find vm with given vm cid", func() {
			_, err := action.Run(1234)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when vm is found with given vm cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("deletes vm", func() {
				_, err := action.Run(1234)
				Expect(err).ToNot(HaveOccurred())

				Expect(vm.DeleteCalled).To(BeTrue())
			})
		vmFinder = &fakevm.FakeFinder{}
		action = NewConfigureNetworks(vmFinder)
		networks = bslcvm.Networks{}
	})

	Describe("Run", func() {
		It("tries to find vm with given vm cid", func() {
			_, err := action.Run(1234, networks)
			Expect(err).ToNot(HaveOccurred())

			Expect(vmFinder.FindID).To(Equal(1234))
		})

		Context("when vm is found with given vm cid", func() {
			var (
				vm *fakevm.FakeVM
			)

			BeforeEach(func() {
				vm = fakevm.NewFakeVM(1234)
				vmFinder.FindVM = vm
				vmFinder.FindFound = true
			})

			It("configures vm networks", func() {
				_, err := action.Run(1234, networks)
				Expect(err).ToNot(HaveOccurred())

				Expect(vm.ConfigureNetworksCalled).To(BeTrue())
				Expect(vm.Networks).To(Equal(networks))
			})