Skip to content

Commit

Permalink
update bigtable app profile test
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 committed Aug 13, 2019
1 parent 40ecf49 commit bf19fd2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
2 changes: 1 addition & 1 deletion templates/terraform/encoders/app_profile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
obj["multiClusterRoutingUseAny"] = bigtableadmin.MultiClusterRoutingUseAny{}
}

return obj, nil
return obj, nil
37 changes: 5 additions & 32 deletions third_party/terraform/tests/resource_bigtable_app_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ func TestAccBigtableAppProfile_singleClusterRouting(t *testing.T) {
Steps: []resource.TestStep{
{
Config: testAccBigtableAppProfile_singleClusterRouting(instanceName),
Check: resource.ComposeTestCheckFunc(
testAccBigtableAppProfileExists(
"google_bigtable_app_profile.ap"),
),
},
{
ResourceName: "google_bigtable_app_profile.ap",
ImportState: true,
ImportStateVerify: true,
},
},
})
Expand Down Expand Up @@ -77,34 +78,6 @@ func testAccCheckBigtableAppProfileDestroy(s *terraform.State) error {
return nil
}

func testAccBigtableAppProfileExists(n string) resource.TestCheckFunc {
var ctx = context.Background()
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n]
if !ok {
return fmt.Errorf("Not found: %s", n)
}

if rs.Primary.ID == "" {
return fmt.Errorf("No ID is set")
}
config := testAccProvider.Meta().(*Config)
c, err := config.bigtableClientFactory.NewInstanceAdminClient(config.Project)
if err != nil {
return fmt.Errorf("Error starting instance admin client. %s", err)
}

defer c.Close()

_, err = c.GetAppProfile(ctx, rs.Primary.Attributes["instance"], rs.Primary.Attributes["app_profile_id"])
if err != nil {
return fmt.Errorf("Error retrieving app profile %s for instance %s.", rs.Primary.Attributes["app_profile_id"], rs.Primary.Attributes["instance"])
}

return nil
}
}

func testAccBigtableAppProfile_multiClusterRouting(instanceName string) string {
return fmt.Sprintf(`
resource "google_bigtable_instance" "instance" {
Expand Down

0 comments on commit bf19fd2

Please sign in to comment.