From d9dcb5d6be091da70d33886a19a9224e3d3691fa Mon Sep 17 00:00:00 2001 From: Dean Smith Date: Tue, 29 Aug 2017 14:10:27 +0100 Subject: Adding tests for machine and arch domain attributes from #166 --- libvirt/resource_libvirt_domain_test.go | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'libvirt') diff --git a/libvirt/resource_libvirt_domain_test.go b/libvirt/resource_libvirt_domain_test.go index e4d2f542..eaaa2345 100644 --- a/libvirt/resource_libvirt_domain_test.go +++ b/libvirt/resource_libvirt_domain_test.go @@ -683,3 +683,55 @@ func TestAccLibvirtDomain_FirmwareTemplate(t *testing.T) { }, }) } + +func TestAccLibvirtDomain_MachineType(t *testing.T) { + var domain libvirt.Domain + + // Using machine type of pc as this is earliest QEMU target + // and so most likely to be available + var config = fmt.Sprintf(` + resource "libvirt_domain" "acceptance-test-domain" { + name = "terraform-test" + machine = "pc" + }`) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLibvirtDomainDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: config, + Check: resource.ComposeTestCheckFunc( + testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain), + resource.TestCheckResourceAttr("libvirt_domain.acceptance-test-domain", "machine", "pc"), + ), + }, + }, + }) +} + +func TestAccLibvirtDomain_ArchType(t *testing.T) { + var domain libvirt.Domain + + // Using i686 as architecture in case anyone running tests on an i686 only host + var config = fmt.Sprintf(` + resource "libvirt_domain" "acceptance-test-domain" { + name = "terraform-test" + arch = "i686" + }`) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLibvirtDomainDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: config, + Check: resource.ComposeTestCheckFunc( + testAccCheckLibvirtDomainExists("libvirt_domain.acceptance-test-domain", &domain), + resource.TestCheckResourceAttr("libvirt_domain.acceptance-test-domain", "arch", "i686"), + ), + }, + }, + }) +} -- cgit v1.2.3