From 106c023a29f3b94e27a8c1c8a0c3632591da4305 Mon Sep 17 00:00:00 2001 From: Ola Karlsson Date: Fri, 28 Apr 2017 04:44:37 +0000 Subject: [PATCH 1/3] Adding import for the compute_route resource --- .../google/import_compute_route_test.go | 45 +++++++++++++++++++ .../google/resource_compute_route.go | 3 ++ 2 files changed, 48 insertions(+) create mode 100644 builtin/providers/google/import_compute_route_test.go diff --git a/builtin/providers/google/import_compute_route_test.go b/builtin/providers/google/import_compute_route_test.go new file mode 100644 index 000000000..1eedeb79e --- /dev/null +++ b/builtin/providers/google/import_compute_route_test.go @@ -0,0 +1,45 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccComputeRoute_importBasic(t *testing.T) { + resourceName := "google_compute_network.foobar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeNetworkDestroy, + Steps: []resource.TestStep{ + { + Config: testAccComputeRoute_basic, + }, { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccComputeRoute_importDefaultInternetGateway(t *testing.T) { + resourceName := "google_compute_network.foobar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckComputeNetworkDestroy, + Steps: []resource.TestStep{ + { + Config: testAccComputeRoute_defaultInternetGateway, + }, { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} diff --git a/builtin/providers/google/resource_compute_route.go b/builtin/providers/google/resource_compute_route.go index ac5760f96..3d7b80616 100644 --- a/builtin/providers/google/resource_compute_route.go +++ b/builtin/providers/google/resource_compute_route.go @@ -14,6 +14,9 @@ func resourceComputeRoute() *schema.Resource { Create: resourceComputeRouteCreate, Read: resourceComputeRouteRead, Delete: resourceComputeRouteDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "dest_range": &schema.Schema{ From b88098b51159da5e8e4b519b5a97db94ecefdd09 Mon Sep 17 00:00:00 2001 From: Ola Karlsson Date: Fri, 28 Apr 2017 05:37:12 +0000 Subject: [PATCH 2/3] Messed up the CheckDestroy attributes. --- builtin/providers/google/import_compute_route_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/providers/google/import_compute_route_test.go b/builtin/providers/google/import_compute_route_test.go index 1eedeb79e..71e8b004a 100644 --- a/builtin/providers/google/import_compute_route_test.go +++ b/builtin/providers/google/import_compute_route_test.go @@ -12,7 +12,7 @@ func TestAccComputeRoute_importBasic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckComputeNetworkDestroy, + CheckDestroy: testAccCheckComputeRouteDestroy, Steps: []resource.TestStep{ { Config: testAccComputeRoute_basic, @@ -31,7 +31,7 @@ func TestAccComputeRoute_importDefaultInternetGateway(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckComputeNetworkDestroy, + CheckDestroy: testAccCheckComputeRouteDestroy, Steps: []resource.TestStep{ { Config: testAccComputeRoute_defaultInternetGateway, From b35f0040475539213bc5df09dfb07bdd0edb12cb Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 4 May 2017 19:17:25 +0300 Subject: [PATCH 3/3] provider/google: Minor formatting issues on import of compute route test --- builtin/providers/google/import_compute_route_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/builtin/providers/google/import_compute_route_test.go b/builtin/providers/google/import_compute_route_test.go index 71e8b004a..a4bfb9893 100644 --- a/builtin/providers/google/import_compute_route_test.go +++ b/builtin/providers/google/import_compute_route_test.go @@ -16,7 +16,8 @@ func TestAccComputeRoute_importBasic(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccComputeRoute_basic, - }, { + }, + { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, @@ -35,7 +36,8 @@ func TestAccComputeRoute_importDefaultInternetGateway(t *testing.T) { Steps: []resource.TestStep{ { Config: testAccComputeRoute_defaultInternetGateway, - }, { + }, + { ResourceName: resourceName, ImportState: true, ImportStateVerify: true,