From 9d3bfb5aaf0b51695a2dae54ede7845660d8eb70 Mon Sep 17 00:00:00 2001 From: Dario Maiocchi Date: Tue, 14 Nov 2017 20:22:55 +0100 Subject: Add AcceptTest for CloudInit --- libvirt/cloudinit_def_test.go | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/libvirt/cloudinit_def_test.go b/libvirt/cloudinit_def_test.go index ab01f4e7..18c63a07 100644 --- a/libvirt/cloudinit_def_test.go +++ b/libvirt/cloudinit_def_test.go @@ -1,11 +1,12 @@ package libvirt import ( + "fmt" + "github.com/hashicorp/terraform/helper/resource" "os" "path/filepath" "strings" "testing" - "gopkg.in/yaml.v2" ) @@ -161,6 +162,34 @@ ssh_authorized_keys: } } +func TestCreateCloudIsoViaPlugin(t *testing.T) { + var config = fmt.Sprintf(` + + resource "libvirt_cloudinit" "test" { + name = "commoninit.iso" + local_hostname = "tango" + pool = "default" + user_data = "#cloud-config\nssh_authorized_keys: []\n" + } + `) + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLibvirtIgnitionDestroy, + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr( + "libvirt_cloudinit.test", "name", "commoninit.iso"), + resource.TestCheckResourceAttr( + "libvirt_cloudinit.test", "local_hostname", "tango"), + ), + }, + }, + }) +} + func exists(path string) (bool, error) { _, err := os.Stat(path) if err == nil { -- cgit v1.2.3