@@ -5,6 +5,7 @@ package nsxt
5
5
6
6
import (
7
7
"fmt"
8
+ tf_api "github.com/vmware/terraform-provider-nsxt/api/utl"
8
9
"testing"
9
10
10
11
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -30,17 +31,21 @@ func TestAccDataSourceNsxtPolicyQosProfile_multitenancy(t *testing.T) {
30
31
func testAccDataSourceNsxtPolicyQosProfileBasic (t * testing.T , withContext bool , preCheck func ()) {
31
32
name := getAccTestDataSourceName ()
32
33
testResourceName := "data.nsxt_policy_qos_profile.test"
34
+ var clientType tf_api.ClientType = tf_api .Local
35
+ if withContext {
36
+ clientType = tf_api .Multitenancy
37
+ }
33
38
34
39
resource .Test (t , resource.TestCase {
35
40
PreCheck : preCheck ,
36
41
Providers : testAccProviders ,
37
42
CheckDestroy : func (state * terraform.State ) error {
38
- return testAccDataSourceNsxtPolicyQosProfileDeleteByName (name )
43
+ return testAccDataSourceNsxtPolicyQosProfileDeleteByName (name , clientType )
39
44
},
40
45
Steps : []resource.TestStep {
41
46
{
42
47
PreConfig : func () {
43
- if err := testAccDataSourceNsxtPolicyQosProfileCreate (name ); err != nil {
48
+ if err := testAccDataSourceNsxtPolicyQosProfileCreate (name , clientType ); err != nil {
44
49
t .Error (err )
45
50
}
46
51
},
@@ -55,7 +60,7 @@ func testAccDataSourceNsxtPolicyQosProfileBasic(t *testing.T, withContext bool,
55
60
})
56
61
}
57
62
58
- func testAccDataSourceNsxtPolicyQosProfileCreate (name string ) error {
63
+ func testAccDataSourceNsxtPolicyQosProfileCreate (name string , clientType tf_api. ClientType ) error {
59
64
connector , err := testAccGetPolicyConnector ()
60
65
if err != nil {
61
66
return fmt .Errorf ("Error during test client initialization: %v" , err )
@@ -71,7 +76,7 @@ func testAccDataSourceNsxtPolicyQosProfileCreate(name string) error {
71
76
// Generate a random ID for the resource
72
77
id := newUUID ()
73
78
74
- client := infra .NewQosProfilesClient (testAccGetSessionContext ( ), connector )
79
+ client := infra .NewQosProfilesClient (testAccGetContextByType ( clientType ), connector )
75
80
if client == nil {
76
81
return policyResourceNotSupportedError ()
77
82
}
@@ -83,14 +88,14 @@ func testAccDataSourceNsxtPolicyQosProfileCreate(name string) error {
83
88
return nil
84
89
}
85
90
86
- func testAccDataSourceNsxtPolicyQosProfileDeleteByName (name string ) error {
91
+ func testAccDataSourceNsxtPolicyQosProfileDeleteByName (name string , clientType tf_api. ClientType ) error {
87
92
connector , err := testAccGetPolicyConnector ()
88
93
if err != nil {
89
94
return fmt .Errorf ("Error during test client initialization: %v" , err )
90
95
}
91
96
92
97
// Find the object by name and delete it
93
- client := infra .NewQosProfilesClient (testAccGetSessionContext ( ), connector )
98
+ client := infra .NewQosProfilesClient (testAccGetContextByType ( clientType ), connector )
94
99
if client == nil {
95
100
return policyResourceNotSupportedError ()
96
101
}
@@ -113,7 +118,7 @@ func testAccDataSourceNsxtPolicyQosProfileDeleteByName(name string) error {
113
118
func testAccNsxtPolicyQosProfileReadTemplate (name string , withContext bool ) string {
114
119
context := ""
115
120
if withContext {
116
- context = testAccNsxtPolicyMultitenancyContext ()
121
+ context = testAccNsxtProjectContext ()
117
122
}
118
123
return fmt .Sprintf (`
119
124
data "nsxt_policy_qos_profile" "test" {
0 commit comments