disk = testhelpers.CreateDisk(20, strconv.Itoa(vm.Datacenter.Id)) strVGID = strconv.Itoa(vmId) strDID = strconv.Itoa(disk.Id) replacementMap = map[string]string{ "VMID": strVGID, "DiskID": strDID, } }) AfterEach(func() { testhelpers.DeleteVirtualGuest(vmId) testhelpers.WaitForVirtualGuestToHaveNoActiveTransactionsOrToErr(vmId) testhelpers.DeleteDisk(disk.Id) testhelpers.DeleteSshKey(createdSshKey.Id) }) It("attach_disk successfully", func() { jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("attach_disk", rootTemplatePath, replacementMap) Expect(err).ToNot(HaveOccurred()) log.Println("jsonPayload --> ", jsonPayload) log.Println("---> starting attach disk") outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload) log.Println("outputBytes=" + string(outputBytes)) Expect(err).ToNot(HaveOccurred()) err = json.Unmarshal(outputBytes, &resultOutput) Expect(err).ToNot(HaveOccurred()) Expect(resultOutput["result"]).To(BeNil())
replacementMap = map[string]string{ "ID": strVGID, } }) AfterEach(func() { testhelpers.DeleteVirtualGuest(virtualGuest.Id) testhelpers.WaitForVirtualGuestToHaveNoActiveTransactionsOrToErr(virtualGuest.Id) testhelpers.DeleteSshKey(createdSshKey.Id) }) It("returns valid result because valid parameters", func() { jsonPayload, err := testhelperscpi.GenerateCpiJsonPayload("create_disk", rootTemplatePath, replacementMap) Expect(err).ToNot(HaveOccurred()) outputBytes, err := testhelperscpi.RunCpi(rootTemplatePath, tmpConfigPath, jsonPayload) log.Println("outputBytes=" + string(outputBytes)) Expect(err).ToNot(HaveOccurred()) err = json.Unmarshal(outputBytes, &resultOutput) Expect(err).ToNot(HaveOccurred()) Expect(resultOutput["result"]).ToNot(BeNil()) Expect(resultOutput["error"]).To(BeNil()) id := resultOutput["result"].(string) diskId, err := strconv.Atoi(id) testhelpers.DeleteDisk(diskId) }) }) })