forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_bigquery_reservation_generated_test.go
96 lines (82 loc) · 2.72 KB
/
resource_bigquery_reservation_generated_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import (
"fmt"
"strings"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
func TestAccBigqueryReservationReservation_bigqueryReservationBasicExample(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": randString(t, 10),
}
vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckBigqueryReservationReservationDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBigqueryReservationReservation_bigqueryReservationBasicExample(context),
},
{
ResourceName: "google_bigquery_reservation.reservation",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name"},
},
},
})
}
func testAccBigqueryReservationReservation_bigqueryReservationBasicExample(context map[string]interface{}) string {
return Nprintf(`
resource "google_bigquery_reservation" "reservation" {
name = "tf-test-my-reservation%{random_suffix}"
location = "asia-northeast1"
// Set to 0 for testing purposes
// In reality this would be larger than zero
slot_capacity = 0
ignore_idle_slots = false
concurrency = 0
}
`, context)
}
func testAccCheckBigqueryReservationReservationDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_bigquery_reservation" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}
config := googleProviderConfig(t)
url, err := replaceVarsForTest(config, rs, "{{BigqueryReservationBasePath}}projects/{{project}}/locations/{{location}}/reservations/{{name}}")
if err != nil {
return err
}
billingProject := ""
if config.BillingProject != "" {
billingProject = config.BillingProject
}
_, err = sendRequest(config, "GET", billingProject, url, config.userAgent, nil)
if err == nil {
return fmt.Errorf("BigqueryReservationReservation still exists at %s", url)
}
}
return nil
}
}