diff --git a/builtin/providers/triton/resource_machine_test.go b/builtin/providers/triton/resource_machine_test.go index 78f3ec290..f6f43bb77 100644 --- a/builtin/providers/triton/resource_machine_test.go +++ b/builtin/providers/triton/resource_machine_test.go @@ -263,6 +263,8 @@ func TestAccTritonMachine_metadata(t *testing.T) { machineName := fmt.Sprintf("acctest-%d", acctest.RandInt()) basic := fmt.Sprintf(testAccTritonMachine_metadata_1, machineName) add_metadata := fmt.Sprintf(testAccTritonMachine_metadata_1, machineName) + add_metadata_2 := fmt.Sprintf(testAccTritonMachine_metadata_2, machineName) + add_metadata_3 := fmt.Sprintf(testAccTritonMachine_metadata_3, machineName) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -283,15 +285,29 @@ func TestAccTritonMachine_metadata(t *testing.T) { "triton_machine.test", "user_data", "hello"), ), }, + resource.TestStep{ + Config: add_metadata_2, + Check: resource.ComposeTestCheckFunc( + testCheckTritonMachineExists("triton_machine.test"), + resource.TestCheckResourceAttr( + "triton_machine.test", + "tags.triton.cns.services", "test-cns-service"), + ), + }, + resource.TestStep{ + Config: add_metadata_3, + Check: resource.ComposeTestCheckFunc( + testCheckTritonMachineExists("triton_machine.test"), + resource.TestCheckResourceAttr( + "triton_machine.test", + "tags.triton.cns.services", "test-cns-service"), + ), + }, }, }) } var testAccTritonMachine_basic = ` -provider "triton" { - url = "https://us-west-1.api.joyentcloud.com" -} - resource "triton_machine" "test" { name = "%s" package = "g4-general-4G" @@ -304,10 +320,6 @@ resource "triton_machine" "test" { ` var testAccTritonMachine_firewall_0 = ` -provider "triton" { - url = "https://us-west-1.api.joyentcloud.com" -} - resource "triton_machine" "test" { name = "%s" package = "g4-general-4G" @@ -317,10 +329,6 @@ resource "triton_machine" "test" { } ` var testAccTritonMachine_firewall_1 = ` -provider "triton" { - url = "https://us-west-1.api.joyentcloud.com" -} - resource "triton_machine" "test" { name = "%s" package = "g4-general-4G" @@ -331,10 +339,6 @@ resource "triton_machine" "test" { ` var testAccTritonMachine_metadata_1 = ` -provider "triton" { - url = "https://us-west-1.api.joyentcloud.com" -} - resource "triton_machine" "test" { name = "%s" package = "g4-general-4G" @@ -347,7 +351,37 @@ resource "triton_machine" "test" { } } ` +var testAccTritonMachine_metadata_2 = ` +variable "tags" { + default = { + test = "hello!" + triton.cns.services = "test-cns-service" + } +} +resource "triton_machine" "test" { + name = "%s" + package = "g4-highcpu-128M" + image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e" + user_data = "hello" + + tags = "${var.tags}" +} +` +var testAccTritonMachine_metadata_3 = ` +resource "triton_machine" "test" { + name = "%s" + package = "g4-highcpu-128M" + image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e" + + user_data = "hello" + + tags = { + test = "hello!" + triton.cns.services = "test-cns-service" + } +} +` var testAccTritonMachine_withnic = ` resource "triton_fabric" "test" { name = "%s-network"