|
| 1 | +// ---------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** |
| 4 | +// |
| 5 | +// ---------------------------------------------------------------------------- |
| 6 | +// |
| 7 | +// This file is automatically generated by Magic Modules and manual |
| 8 | +// changes will be clobbered when the file is regenerated. |
| 9 | +// |
| 10 | +// Please read more about how to change this file in |
| 11 | +// .github/CONTRIBUTING.md. |
| 12 | +// |
| 13 | +// ---------------------------------------------------------------------------- |
| 14 | + |
| 15 | +package google |
| 16 | + |
| 17 | +import ( |
| 18 | + "fmt" |
| 19 | + "strings" |
| 20 | + "testing" |
| 21 | + |
| 22 | + "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" |
| 23 | + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" |
| 24 | + "github.com/hashicorp/terraform-plugin-sdk/terraform" |
| 25 | +) |
| 26 | + |
| 27 | +func TestAccGameServicesGameServerCluster_gameServiceClusterBasicExample(t *testing.T) { |
| 28 | + t.Parallel() |
| 29 | + |
| 30 | + context := map[string]interface{}{ |
| 31 | + "agones_cluster": "bootstrapped-agones-cluster", |
| 32 | + "random_suffix": acctest.RandString(10), |
| 33 | + } |
| 34 | + |
| 35 | + resource.Test(t, resource.TestCase{ |
| 36 | + PreCheck: func() { testAccPreCheck(t) }, |
| 37 | + Providers: testAccProvidersOiCS, |
| 38 | + CheckDestroy: testAccCheckGameServicesGameServerClusterDestroy, |
| 39 | + Steps: []resource.TestStep{ |
| 40 | + { |
| 41 | + Config: testAccGameServicesGameServerCluster_gameServiceClusterBasicExample(context), |
| 42 | + }, |
| 43 | + }, |
| 44 | + }) |
| 45 | +} |
| 46 | + |
| 47 | +func testAccGameServicesGameServerCluster_gameServiceClusterBasicExample(context map[string]interface{}) string { |
| 48 | + return Nprintf(` |
| 49 | +resource "google_game_services_game_server_cluster" "default" { |
| 50 | + provider = google-beta |
| 51 | + |
| 52 | + cluster_id = "%{agones_cluster}" |
| 53 | + realm_id = google_game_services_realm.default.realm_id |
| 54 | +
|
| 55 | + connection_info { |
| 56 | + gke_cluster_reference { |
| 57 | + cluster = "locations/us-west1/clusters/%{agones_cluster}" |
| 58 | + } |
| 59 | + namespace = "default" |
| 60 | + } |
| 61 | +} |
| 62 | +
|
| 63 | +resource "google_game_services_realm" "default" { |
| 64 | + provider = google-beta |
| 65 | +
|
| 66 | + realm_id = "realm%{random_suffix}" |
| 67 | + time_zone = "PST8PDT" |
| 68 | +
|
| 69 | + description = "Test Game Realm" |
| 70 | +} |
| 71 | +`, context) |
| 72 | +} |
| 73 | + |
| 74 | +func testAccCheckGameServicesGameServerClusterDestroy(s *terraform.State) error { |
| 75 | + for name, rs := range s.RootModule().Resources { |
| 76 | + if rs.Type != "google_game_services_game_server_cluster" { |
| 77 | + continue |
| 78 | + } |
| 79 | + if strings.HasPrefix(name, "data.") { |
| 80 | + continue |
| 81 | + } |
| 82 | + |
| 83 | + config := testAccProvider.Meta().(*Config) |
| 84 | + |
| 85 | + url, err := replaceVarsForTest(config, rs, "{{GameServicesBasePath}}projects/{{project}}/locations/{{location}}/realms/{{realm_id}}/gameServerClusters/{{cluster_id}}") |
| 86 | + if err != nil { |
| 87 | + return err |
| 88 | + } |
| 89 | + |
| 90 | + _, err = sendRequest(config, "GET", "", url, nil) |
| 91 | + if err == nil { |
| 92 | + return fmt.Errorf("GameServicesGameServerCluster still exists at %s", url) |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + return nil |
| 97 | +} |
0 commit comments