From d3488bf8f1d7d0884e4ccf011a827825c4420bb4 Mon Sep 17 00:00:00 2001 From: 4censord Date: Thu, 6 Oct 2022 21:52:06 +0200 Subject: [PATCH] Add an acceptance test --- xoa/resource_xenorchestra_vm_test.go | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/xoa/resource_xenorchestra_vm_test.go b/xoa/resource_xenorchestra_vm_test.go index 0d8300df..2bf506bd 100644 --- a/xoa/resource_xenorchestra_vm_test.go +++ b/xoa/resource_xenorchestra_vm_test.go @@ -576,6 +576,27 @@ func TestAccXenorchestraVm_createWithDisklessTemplateAndISO(t *testing.T) { }) } +func TestAccXenorchestraVm_createWithoutDisks(t *testing.T) { + resourceName := "xenorchestra_vm.bar" + vmName := fmt.Sprintf("%s - %s", accTestPrefix, t.Name()) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckXenorchestraVmDestroy, + Steps: []resource.TestStep{ + { + Config: testAccVmConfigWithoutDisks(vmName), + Check: resource.ComposeAggregateTestCheckFunc( + testAccVmExists(resourceName), + resource.TestCheckResourceAttrSet(resourceName, "id"), + resource.TestCheckResourceAttr(resourceName, "cdrom.#", "1"), + internal.TestCheckTypeSetElemAttrPair(resourceName, "cdrom.0.*", "data.xenorchestra_vdi.iso", "id"), + ), + }, + }, + }) +} + func TestAccXenorchestraVm_insertAndEjectCd(t *testing.T) { resourceName := "xenorchestra_vm.bar" vmName := fmt.Sprintf("%s - %s", accTestPrefix, t.Name()) @@ -1542,6 +1563,36 @@ resource "xenorchestra_vm" "bar" { `, testIsoName, accTestPool.Id, accDefaultNetwork.NameLabel, accTestPool.Id, vmName, accDefaultSr.Id) } +func testAccVmConfigWithoutDisks(vmName string) string { + return testAccCloudConfigConfig(fmt.Sprintf("vm-template-%s", vmName), "template") + testAccNonDefaultTemplateConfig(disklessTestTemplate.NameLabel) + fmt.Sprintf(` +data "xenorchestra_vdi" "iso" { + name_label = "%s" + pool_id = "%s" +} + +data "xenorchestra_network" "network" { + name_label = "%s" + pool_id = "%s" +} + +resource "xenorchestra_vm" "bar" { + memory_max = 4295000000 + cpus = 1 + cloud_config = "${xenorchestra_cloud_config.bar.template}" + name_label = "%s" + name_description = "description" + template = "${data.xenorchestra_template.template.id}" + network { + network_id = "${data.xenorchestra_network.network.id}" + } + + cdrom { + id = data.xenorchestra_vdi.iso.id + } +} +`, testIsoName, accTestPool.Id, accDefaultNetwork.NameLabel, accTestPool.Id, vmName, accDefaultSr.Id) +} + func testAccVmConfigWithoutISO(vmName string) string { return testAccCloudConfigConfig(fmt.Sprintf("vm-template-%s", vmName), "template") + testAccNonDefaultTemplateConfig(disklessTestTemplate.NameLabel) + fmt.Sprintf(`