@@ -35,7 +35,40 @@ func TestAccDataSourceNsxtPolicyVPC_basic_multitenancy(t *testing.T) {
35
35
t .Error (err )
36
36
}
37
37
},
38
- Config : testAccNsxtPolicyVPCReadTemplate (name ),
38
+ Config : testAccNsxtPolicyVPCReadTemplate (name , true ),
39
+ Check : resource .ComposeTestCheckFunc (
40
+ resource .TestCheckResourceAttr (testResourceName , "display_name" , name ),
41
+ resource .TestCheckResourceAttr (testResourceName , "description" , name ),
42
+ resource .TestCheckResourceAttrSet (testResourceName , "path" ),
43
+ resource .TestCheckResourceAttrSet (testResourceName , "short_id" ),
44
+ ),
45
+ },
46
+ },
47
+ })
48
+ }
49
+
50
+ func TestAccDataSourceNsxtPolicyVPC_basic_multitenancyProvider (t * testing.T ) {
51
+ name := getAccTestDataSourceName ()
52
+ testResourceName := "data.nsxt_policy_vpc.test"
53
+
54
+ resource .ParallelTest (t , resource.TestCase {
55
+ PreCheck : func () {
56
+ testAccOnlyMultitenancyProvider (t )
57
+ testAccPreCheck (t )
58
+ testAccNSXVersion (t , "4.1.2" )
59
+ },
60
+ Providers : testAccProviders ,
61
+ CheckDestroy : func (state * terraform.State ) error {
62
+ return testAccDataSourceNsxtPolicyVPCDeleteByName (name )
63
+ },
64
+ Steps : []resource.TestStep {
65
+ {
66
+ PreConfig : func () {
67
+ if err := testAccDataSourceNsxtPolicyVPCCreate (name ); err != nil {
68
+ t .Error (err )
69
+ }
70
+ },
71
+ Config : testAccNsxtPolicyVPCReadTemplate (name , false ),
39
72
Check : resource .ComposeTestCheckFunc (
40
73
resource .TestCheckResourceAttr (testResourceName , "display_name" , name ),
41
74
resource .TestCheckResourceAttr (testResourceName , "description" , name ),
@@ -113,8 +146,11 @@ func testAccDataSourceNsxtPolicyVPCDeleteByName(name string) error {
113
146
return fmt .Errorf ("error while deleting VPC '%s': resource not found" , name )
114
147
}
115
148
116
- func testAccNsxtPolicyVPCReadTemplate (name string ) string {
117
- context := testAccNsxtPolicyMultitenancyContext ()
149
+ func testAccNsxtPolicyVPCReadTemplate (name string , withContext bool ) string {
150
+ context := ""
151
+ if withContext {
152
+ context = testAccNsxtPolicyMultitenancyContext ()
153
+ }
118
154
return fmt .Sprintf (`
119
155
data "nsxt_policy_ip_block" "test" {
120
156
%s
0 commit comments