testhelpers.SetTestFixtureForFakeSoftLayerClient(softLayerClient, "SoftLayer_Virtual_Guest_Service_getObject.json") }) Describe("Find", func() { var ( vmID int ) Context("when the VM ID is valid and existing", func() { BeforeEach(func() { vmID = 1234 }) It("finds and returns a new SoftLayerVM object with correct ID", func() { vm, found, err := finder.Find(vmID) Expect(err).ToNot(HaveOccurred()) Expect(found).To(BeTrue(), "could not find VM") Expect(vm.ID()).To(Equal(vmID), "found VM but ID does not match") }) }) Context("when the VM ID does not exist", func() { It("fails finding the VM", func() { _, found, _ := finder.Find(000000) Expect(found).To(BeFalse()) }) }) }) })
GlobalIdentifier: "fake-uuid", }, RootDiskSize: 25, EphemeralDiskSize: 25, Datacenter: sldatatypes.Datacenter{Name: "fake-datacenter"}, } networks = Networks{} env = Environment{} setFakeSoftLayerClientCreateObjectTestFixtures(softLayerClient) }) It("returns a new SoftLayerVM with correct virtual guest ID and SoftLayerClient", func() { vm, err := creator.Create(agentID, stemcell, cloudProps, networks, env) Expect(err).ToNot(HaveOccurred()) Expect(vm.ID()).To(Equal(1234567)) }) }) Context("invalid arguments", func() { Context("missing correct VMProperties", func() { BeforeEach(func() { agentID = "fake-agent-id" stemcell = bslcstem.NewSoftLayerStemcell(1234, "fake-stemcell-uuid", fakestem.FakeStemcellKind, softLayerClient, logger) networks = Networks{} env = Environment{} setFakeSoftLayerClientCreateObjectTestFixtures(softLayerClient) }) It("fails when VMProperties is missing StartCpus", func() {