Skip to content

Commit

Permalink
Add AccTest for tags with dots for Triton provider
Browse files Browse the repository at this point in the history
- Tests for issue hashicorp/terraform#2143.
- Fixed package names since Triton deprecated the g3-series.
- Must supply SDC_URL when invoking tests.

Test will fail on metadata_3 but not on _2 as discussed with
@jen20 on 11 June 2016.
  • Loading branch information
sodre committed Jun 12, 2016
1 parent 7d53e65 commit 15051f5
Showing 1 changed file with 56 additions and 22 deletions.
78 changes: 56 additions & 22 deletions resource_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,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) },
Expand All @@ -253,18 +255,32 @@ 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 = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
tags = {
Expand All @@ -274,40 +290,28 @@ 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 = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
firewall_enabled = 0
}
`
var testAccTritonMachine_firewall_1 = `
provider "triton" {
url = "https://us-west-1.api.joyentcloud.com"
}
resource "triton_machine" "test" {
name = "%s"
package = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
firewall_enabled = 1
}
`

var testAccTritonMachine_metadata_1 = `
provider "triton" {
url = "https://us-west-1.api.joyentcloud.com"
}
resource "triton_machine" "test" {
name = "%s"
package = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "c20b4b7c-e1a6-11e5-9a4d-ef590901732e"
user_data = "hello"
Expand All @@ -317,7 +321,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"
Expand All @@ -334,7 +368,7 @@ resource "triton_fabric" "test" {
resource "triton_machine" "test" {
name = "%s"
package = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "842e6fa6-6e9b-11e5-8402-1b490459e334"
tags = {
Expand All @@ -361,7 +395,7 @@ resource "triton_fabric" "test" {
resource "triton_machine" "test" {
name = "%s"
package = "g3-standard-0.25-smartos"
package = "g4-highcpu-128M"
image = "842e6fa6-6e9b-11e5-8402-1b490459e334"
tags = {
Expand Down

0 comments on commit 15051f5

Please sign in to comment.