From 94608fc4bc318604b3ba47125660d6373ea76cfa Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Mon, 9 Mar 2015 17:44:09 +0100 Subject: [PATCH] Fixing up the tests to make them pass correctly --- builtin/providers/cloudstack/provider.go | 2 +- ...resource_cloudstack_vpn_connection_test.go | 14 ++--- ...ce_cloudstack_vpn_customer_gateway_test.go | 54 +++++++++---------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/builtin/providers/cloudstack/provider.go b/builtin/providers/cloudstack/provider.go index f7ce62725..8bea67ef5 100644 --- a/builtin/providers/cloudstack/provider.go +++ b/builtin/providers/cloudstack/provider.go @@ -30,7 +30,7 @@ func Provider() terraform.ResourceProvider { "timeout": &schema.Schema{ Type: schema.TypeInt, Required: true, - DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_TIMEOUT", 180), + DefaultFunc: schema.EnvDefaultFunc("CLOUDSTACK_TIMEOUT", 300), }, }, diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go index ff7a46fd3..1b9d9920a 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_connection_test.go @@ -21,7 +21,9 @@ func TestAccCloudStackVPNConnection_basic(t *testing.T) { Config: testAccCloudStackVPNConnection_basic, Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackVPNConnectionExists( - "cloudstack_vpn_connection.foo", &vpnConnection), + "cloudstack_vpn_connection.foo-bar", &vpnConnection), + testAccCheckCloudStackVPNConnectionExists( + "cloudstack_vpn_connection.bar-foo", &vpnConnection), ), }, }, @@ -84,16 +86,14 @@ func testAccCheckCloudStackVPNConnectionDestroy(s *terraform.State) error { var testAccCloudStackVPNConnection_basic = fmt.Sprintf(` resource "cloudstack_vpc" "foo" { - name = "terraform-vpc" - display_text = "terraform-vpc-text" + name = "terraform-vpc-foo" cidr = "%s" vpc_offering = "%s" zone = "%s" } resource "cloudstack_vpc" "bar" { - name = "terraform-vpc" - display_text = "terraform-vpc-text" + name = "terraform-vpc-bar" cidr = "%s" vpc_offering = "%s" zone = "%s" @@ -111,7 +111,7 @@ resource "cloudstack_vpn_customer_gateway" "foo" { name = "terraform-foo" cidr = "${cloudstack_vpc.foo.cidr}" esp_policy = "aes256-sha1" - gateway = "${cloudstack_vpn_gateway.foo.publicip}" + gateway = "${cloudstack_vpn_gateway.foo.public_ip}" ike_policy = "aes256-sha1" ipsec_psk = "terraform" } @@ -120,7 +120,7 @@ resource "cloudstack_vpn_customer_gateway" "bar" { name = "terraform-bar" cidr = "${cloudstack_vpc.bar.cidr}" esp_policy = "aes256-sha1" - gateway = "${cloudstack_vpn_gateway.bar.publicip}" + gateway = "${cloudstack_vpn_gateway.bar.public_ip}" ike_policy = "aes256-sha1" ipsec_psk = "terraform" } diff --git a/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go b/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go index 9475e31a3..b468c76fe 100644 --- a/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go +++ b/builtin/providers/cloudstack/resource_cloudstack_vpn_customer_gateway_test.go @@ -21,16 +21,16 @@ func TestAccCloudStackVPNCustomerGateway_basic(t *testing.T) { Config: testAccCloudStackVPNCustomerGateway_basic, Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackVPNCustomerGatewayExists( - "cloudstack_vpn_connection.foo", &vpnCustomerGateway), + "cloudstack_vpn_customer_gateway.foo", &vpnCustomerGateway), testAccCheckCloudStackVPNCustomerGatewayAttributes(&vpnCustomerGateway), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "name", "terraform-foo"), + "cloudstack_vpn_customer_gateway.foo", "name", "terraform-foo"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "name", "terraform-bar"), + "cloudstack_vpn_customer_gateway.bar", "name", "terraform-bar"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "ike_policy", "aes256-sha1"), + "cloudstack_vpn_customer_gateway.foo", "ike_policy", "aes256-sha1"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "esp_policy", "aes256-sha1"), + "cloudstack_vpn_customer_gateway.bar", "esp_policy", "aes256-sha1"), ), }, }, @@ -38,44 +38,44 @@ func TestAccCloudStackVPNCustomerGateway_basic(t *testing.T) { } func TestAccCloudStackVPNCustomerGateway_update(t *testing.T) { - var nic cloudstack.Nic + var vpnCustomerGateway cloudstack.VpnCustomerGateway resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckCloudStackNICDestroy, + CheckDestroy: testAccCheckCloudStackVPNCustomerGatewayDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: TestAccCloudStackVPNCustomerGateway_basic, + Config: testAccCloudStackVPNCustomerGateway_basic, Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackVPNCustomerGatewayExists( - "cloudstack_vpn_connection.foo", &vpnCustomerGateway), + "cloudstack_vpn_customer_gateway.foo", &vpnCustomerGateway), testAccCheckCloudStackVPNCustomerGatewayAttributes(&vpnCustomerGateway), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "name", "terraform-foo"), + "cloudstack_vpn_customer_gateway.foo", "name", "terraform-foo"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "name", "terraform-bar"), + "cloudstack_vpn_customer_gateway.bar", "name", "terraform-bar"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "ike_policy", "aes256-sha1"), + "cloudstack_vpn_customer_gateway.foo", "ike_policy", "aes256-sha1"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "esp_policy", "aes256-sha1"), + "cloudstack_vpn_customer_gateway.bar", "esp_policy", "aes256-sha1"), ), }, resource.TestStep{ - Config: TestAccCloudStackVPNCustomerGateway_update, + Config: testAccCloudStackVPNCustomerGateway_update, Check: resource.ComposeTestCheckFunc( testAccCheckCloudStackVPNCustomerGatewayExists( - "cloudstack_vpn_connection.foo", &vpnCustomerGateway), + "cloudstack_vpn_customer_gateway.foo", &vpnCustomerGateway), testAccCheckCloudStackVPNCustomerGatewayAttributes(&vpnCustomerGateway), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "name", "terraform-foo-bar"), + "cloudstack_vpn_customer_gateway.foo", "name", "terraform-foo-bar"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "name", "terraform-bar-foo"), + "cloudstack_vpn_customer_gateway.bar", "name", "terraform-bar-foo"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.foo", "ike_policy", "3des-md5"), + "cloudstack_vpn_customer_gateway.foo", "ike_policy", "3des-md5"), resource.TestCheckResourceAttr( - "cloudstack_vpn_connection.bar", "esp_policy", "3des-md5"), + "cloudstack_vpn_customer_gateway.bar", "esp_policy", "3des-md5"), ), }, }, @@ -135,7 +135,7 @@ func testAccCheckCloudStackVPNCustomerGatewayDestroy(s *terraform.State) error { cs := testAccProvider.Meta().(*cloudstack.CloudStackClient) for _, rs := range s.RootModule().Resources { - if rs.Type != "cloudstack_vpn_connection" { + if rs.Type != "cloudstack_vpn_customer_gateway" { continue } @@ -158,16 +158,14 @@ func testAccCheckCloudStackVPNCustomerGatewayDestroy(s *terraform.State) error { var testAccCloudStackVPNCustomerGateway_basic = fmt.Sprintf(` resource "cloudstack_vpc" "foo" { - name = "terraform-vpc" - display_text = "terraform-vpc-text" + name = "terraform-vpc-foo" cidr = "%s" vpc_offering = "%s" zone = "%s" } resource "cloudstack_vpc" "bar" { - name = "terraform-vpc" - display_text = "terraform-vpc-text" + name = "terraform-vpc-bar" cidr = "%s" vpc_offering = "%s" zone = "%s" @@ -185,7 +183,7 @@ resource "cloudstack_vpn_customer_gateway" "foo" { name = "terraform-foo" cidr = "${cloudstack_vpc.foo.cidr}" esp_policy = "aes256-sha1" - gateway = "${cloudstack_vpn_gateway.foo.publicip}" + gateway = "${cloudstack_vpn_gateway.foo.public_ip}" ike_policy = "aes256-sha1" ipsec_psk = "terraform" } @@ -194,7 +192,7 @@ resource "cloudstack_vpn_customer_gateway" "bar" { name = "terraform-bar" cidr = "${cloudstack_vpc.bar.cidr}" esp_policy = "aes256-sha1" - gateway = "${cloudstack_vpn_gateway.bar.publicip}" + gateway = "${cloudstack_vpn_gateway.bar.public_ip}" ike_policy = "aes256-sha1" ipsec_psk = "terraform" }`, @@ -210,7 +208,7 @@ resource "cloudstack_vpn_customer_gateway" "foo" { name = "terraform-foo-bar" cidr = "${cloudstack_vpc.foo.cidr}" esp_policy = "3des-md5" - gateway = "${cloudstack_vpn_gateway.foo.publicip}" + gateway = "${cloudstack_vpn_gateway.foo.public_ip}" ike_policy = "3des-md5" ipsec_psk = "terraform" } @@ -219,7 +217,7 @@ resource "cloudstack_vpn_customer_gateway" "bar" { name = "terraform-bar-foo" cidr = "${cloudstack_vpc.bar.cidr}" esp_policy = "3des-md5" - gateway = "${cloudstack_vpn_gateway.bar.publicip}" + gateway = "${cloudstack_vpn_gateway.bar.public_ip}" ike_policy = "3des-md5" ipsec_psk = "terraform" }`)