Skip to content

Commit

Permalink
set dc in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ack committed Mar 21, 2016
1 parent 4c4be81 commit 3971f76
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
5 changes: 2 additions & 3 deletions builtin/providers/clc/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider

const testAccDC = "IL1"

func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
Expand All @@ -35,7 +37,4 @@ func testAccPreCheck(t *testing.T) {
if v := os.Getenv("CLC_PASSWORD"); v == "" {
t.Fatal("CLC_PASSWORD must be set for acceptance tests")
}
if v := os.Getenv("CLC_ACCOUNT"); v == "" {
t.Fatal("CLC_ACCOUNT must be set for acceptance tests")
}
}
21 changes: 14 additions & 7 deletions builtin/providers/clc/resource_clc_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestAccGroupBasic(t *testing.T) {
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "name", "okcomputer"),
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "location_id", "WA1"),
"clc_group.acc_test_group", "location_id", testAccDC),
),
},
resource.TestStep{
Expand All @@ -41,7 +41,7 @@ func TestAccGroupBasic(t *testing.T) {
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "name", "foobar"),
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "location_id", "WA1"),
"clc_group.acc_test_group", "location_id", testAccDC),
),
},
resource.TestStep{
Expand All @@ -52,7 +52,7 @@ func TestAccGroupBasic(t *testing.T) {
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "name", "foobar"),
resource.TestCheckResourceAttr(
"clc_group.acc_test_group", "location_id", "WA1"),
"clc_group.acc_test_group", "location_id", testAccDC),
),
},
},
Expand Down Expand Up @@ -117,30 +117,37 @@ func testAccCheckGroupExists(n string, resp *group.Response) resource.TestCheckF
}

const testAccCheckGroupConfigBasic = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group" {
location_id = "WA1"
location_id = "${var.dc}"
name = "okcomputer"
description = "mishaps happening"
parent = "Default Group"
}`

const testAccCheckGroupConfigUpdate = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group" {
location_id = "WA1"
location_id = "${var.dc}"
name = "foobar"
description = "update test"
parent = "Default Group"
}`

const testAccCheckGroupConfigReparent = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_reparent" {
location_id = "WA1"
location_id = "${var.dc}"
name = "reparent"
description = "introduce a parent group in place"
parent = "Default Group"
}
resource "clc_group" "acc_test_group" {
location_id = "WA1"
location_id = "${var.dc}"
name = "foobar"
description = "update test"
parent = "${clc_group.acc_test_group_reparent.id}"
Expand Down
16 changes: 10 additions & 6 deletions builtin/providers/clc/resource_clc_load_balancer_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ func testAccCheckLBPDestroy(s *terraform.State) error {
continue
}
lbid := rs.Primary.Attributes["load_balancer"]
_, err := client.LB.GetPool(testAccDC, lbid, rs.Primary.ID)
if err == nil {
if _, err := client.LB.Get(testAccDC, rs.Primary.ID); err != nil {
return nil // parent LB already gone
}
if _, err := client.LB.GetPool(testAccDC, lbid, rs.Primary.ID); err == nil {
return fmt.Errorf("LB still exists")
}
}
Expand Down Expand Up @@ -72,36 +74,38 @@ func testAccCheckLBPExists(n string, resp *lb.Pool) resource.TestCheckFunc {
}

const testAccCheckLBPConfigBasic = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_lbp_group" {
location_id = "WA1"
location_id = "${var.dc}"
name = "acc_test_lbp_group"
parent = "Default Group"
}
# need a server here because we need to reference an ip owned by this account
resource "clc_server" "acc_test_lbp_server" {
name_template = "node"
description = "load balanced node"
description = "load balanced in ${clc_load_balancer.acc_test_lbp.id}"
source_server_id = "UBUNTU-14-64-TEMPLATE"
type = "standard"
group_id = "${clc_group.acc_test_lbp_group.id}"
cpu = 1
memory_mb = 1024
password = "Green123$"
power_state = "started"
}
resource "clc_load_balancer" "acc_test_lbp" {
data_center = "WA1"
data_center = "${var.dc}"
name = "acc_test_lb"
description = "load balancer test"
status = "enabled"
}
resource "clc_load_balancer_pool" "acc_test_pool" {
port = 80
data_center = "WA1"
data_center = "${var.dc}"
load_balancer = "${clc_load_balancer.acc_test_lbp.id}"
nodes
{
Expand Down
13 changes: 7 additions & 6 deletions builtin/providers/clc/resource_clc_load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
// toggles status
// created w/o pool

const testAccDC = "WA1"

func TestAccLoadBalancerBasic(t *testing.T) {
var resp lb.LoadBalancer
resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -53,8 +51,7 @@ func testAccCheckLBDestroy(s *terraform.State) error {
if rs.Type != "clc_load_balancer" {
continue
}
_, err := client.LB.Get(testAccDC, rs.Primary.ID)
if err == nil {
if _, err := client.LB.Get(testAccDC, rs.Primary.ID); err == nil {
return fmt.Errorf("LB still exists")
}
}
Expand Down Expand Up @@ -84,16 +81,20 @@ func testAccCheckLBExists(n string, resp *lb.LoadBalancer) resource.TestCheckFun
}

const testAccCheckLBConfigBasic = `
variable "dc" { default = "IL1" }
resource "clc_load_balancer" "acc_test_lb" {
data_center = "WA1"
data_center = "${var.dc}"
name = "acc_test_lb"
description = "load balancer test"
status = "enabled"
}`

const testAccCheckLBConfigNameDesc = `
variable "dc" { default = "IL1" }
resource "clc_load_balancer" "acc_test_lb" {
data_center = "WA1"
data_center = "${var.dc}"
name = "foobar"
description = "foobar"
status = "disabled"
Expand Down
4 changes: 3 additions & 1 deletion builtin/providers/clc/resource_clc_public_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ func testAccCheckPublicIPNIC(n string, resp *server.PublicIP) resource.TestCheck
}

var testAccCheckPublicIPConfigBasic = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_ip" {
location_id = "CA1"
location_id = "${var.dc}"
name = "acc_test_group_ip"
parent = "Default Group"
}
Expand Down
16 changes: 12 additions & 4 deletions builtin/providers/clc/resource_clc_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ func testAccCheckServerUpdatedDisks(n string, resp *server.Response) resource.Te
}

const testAccCheckServerConfigBasic = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_server" {
location_id = "WA1"
location_id = "${var.dc}"
name = "acc_test_group_server"
parent = "Default Group"
}
Expand All @@ -194,8 +196,10 @@ resource "clc_server" "acc_test_server" {
`

const testAccCheckServerConfigCPUMEM = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_server" {
location_id = "WA1"
location_id = "${var.dc}"
name = "acc_test_group_server"
parent = "Default Group"
}
Expand All @@ -212,8 +216,10 @@ resource "clc_server" "acc_test_server" {
`

const testAccCheckServerConfigPower = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_server" {
location_id = "WA1"
location_id = "${var.dc}"
name = "acc_test_group_server"
parent = "Default Group"
}
Expand All @@ -230,8 +236,10 @@ resource "clc_server" "acc_test_server" {
`

const testAccCheckServerConfigDisks = `
variable "dc" { default = "IL1" }
resource "clc_group" "acc_test_group_server" {
location_id = "WA1"
location_id = "${var.dc}"
name = "acc_test_group_server"
parent = "Default Group"
}
Expand Down

0 comments on commit 3971f76

Please sign in to comment.