id, err := action.Run("fake-agent-id", stemcellCID, vmCloudProp, networks, diskLocality, env) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-create-err")) Expect(id).To(Equal(VMCID(0))) }) }) Context("when stemcell is not found with given cid", func() { It("returns error because VM cannot be created without a stemcell", func() { stemcellFinder.FindFound = false id, err := action.Run("fake-agent-id", stemcellCID, vmCloudProp, networks, diskLocality, env) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Expected to find stemcell")) Expect(id).To(Equal(VMCID(0))) }) }) Context("when stemcell finding fails", func() { It("returns error because VM cannot be created without a stemcell", func() { stemcellFinder.FindErr = errors.New("fake-find-err") id, err := action.Run("fake-agent-id", stemcellCID, vmCloudProp, networks, diskLocality, env) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("fake-find-err")) Expect(id).To(Equal(VMCID(0))) }) }) }) })