1
1
package gkehub2_test
2
2
3
3
import (
4
+ "fmt"
5
+ "strings"
4
6
"testing"
5
7
6
8
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
9
+ "github.com/hashicorp/terraform-plugin-testing/terraform"
7
10
"github.com/hashicorp/terraform-provider-google/google/acctest"
11
+ "github.com/hashicorp/terraform-provider-google/google/tpgresource"
12
+ transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
8
13
)
9
14
10
15
func TestAccDataSourceGoogleGkeHubFeature_basic (t * testing.T ) {
@@ -34,7 +39,7 @@ func testAccDataSourceGoogleGkeHubFeature_basic(context map[string]interface{})
34
39
resource "google_gke_hub_feature" "example" {
35
40
location = "us-central1"
36
41
project = "%{project}"
37
- name = "configmanagement "
42
+ name = "servicemesh "
38
43
}
39
44
40
45
data "google_gke_hub_feature" "example" {
@@ -44,3 +49,42 @@ data "google_gke_hub_feature" "example" {
44
49
}
45
50
` , context )
46
51
}
52
+
53
+ func testAccCheckGoogleGkeHubFeatureDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
54
+ return func (s * terraform.State ) error {
55
+ for name , rs := range s .RootModule ().Resources {
56
+ if rs .Type != "google_gke_hub_feature" {
57
+ continue
58
+ }
59
+ if strings .HasPrefix (name , "data." ) {
60
+ continue
61
+ }
62
+
63
+ config := acctest .GoogleProviderConfig (t )
64
+
65
+ url , err := tpgresource .ReplaceVarsForTest (config , rs , "{{GKEHub2BasePath}}projects/{{project}}/locations/{{location}}/features/{{name}}" )
66
+ if err != nil {
67
+ return err
68
+ }
69
+
70
+ billingProject := ""
71
+
72
+ if config .BillingProject != "" {
73
+ billingProject = config .BillingProject
74
+ }
75
+
76
+ _ , err = transport_tpg .SendRequest (transport_tpg.SendRequestOptions {
77
+ Config : config ,
78
+ Method : "GET" ,
79
+ Project : billingProject ,
80
+ RawURL : url ,
81
+ UserAgent : config .UserAgent ,
82
+ })
83
+ if err == nil {
84
+ return fmt .Errorf ("GKEHub2Feature still exists at %s" , url )
85
+ }
86
+ }
87
+
88
+ return nil
89
+ }
90
+ }
0 commit comments