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

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

		Context("when disk is found with given disk cid", func() {
			var (
				disk *fakedisk.FakeDisk
			)

			BeforeEach(func() {
				disk = fakedisk.NewFakeDisk(1234)
				diskFinder.FindDisk = disk
				diskFinder.FindFound = true
			})

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

				Expect(disk.DeleteCalled).To(BeTrue())
			})

			It("returns error if deleting disk fails", func() {
				disk.DeleteErr = errors.New("fake-delete-err")

				_, err := action.Run(1234)
)

var _ = Describe("CreateDisk", func() {
	var (
		diskCreator *fakedisk.FakeCreator
		action      CreateDisk
	)

	BeforeEach(func() {
		diskCreator = &fakedisk.FakeCreator{}
		action = NewCreateDisk(diskCreator)
	})

	Describe("Run", func() {
		It("returns id for created disk for specific size", func() {
			diskCreator.CreateDisk = fakedisk.NewFakeDisk(1234)

			id, err := action.Run(20, VMCID(1234))
			Expect(err).ToNot(HaveOccurred())
			Expect(id).To(Equal(DiskCID(1234)))

			Expect(diskCreator.CreateSize).To(Equal(20))
		})

		It("returns error if creating disk fails", func() {
			diskCreator.CreateErr = errors.New("fake-create-err")

			id, err := action.Run(20, VMCID(1234))
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("fake-create-err"))
			Expect(id).To(Equal(DiskCID(0)))
		action     DetachDisk
	)

	BeforeEach(func() {
		vmFinder = &fakevm.FakeFinder{}
		diskFinder = &fakedisk.FakeFinder{}
		action = NewDetachDisk(vmFinder, diskFinder)
	})

	Describe("Run", func() {
		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