forked from vmware/terraform-provider-nsxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_nsxt_policy_edge_cluster_test.go
54 lines (46 loc) · 1.33 KB
/
data_source_nsxt_policy_edge_cluster_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
/* Copyright © 2019 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: MPL-2.0 */
package nsxt
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccDataSourceNsxtPolicyEdgeCluster_basic(t *testing.T) {
edgeClusterName := getEdgeClusterName()
testResourceName := "data.nsxt_policy_edge_cluster.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
testAccNSXGlobalManagerSitePrecheck(t)
},
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccNsxtPolicyEdgeClusterReadTemplate(edgeClusterName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(testResourceName, "display_name"),
resource.TestCheckResourceAttrSet(testResourceName, "path"),
),
},
},
})
}
func testAccNsxtPolicyEdgeClusterReadTemplate(name string) string {
if testAccIsGlobalManager() {
return testAccNsxtGlobalPolicyEdgeClusterReadTemplate()
}
return fmt.Sprintf(`
data "nsxt_policy_edge_cluster" "test" {
display_name = "%s"
}`, name)
}
func testAccNsxtGlobalPolicyEdgeClusterReadTemplate() string {
return fmt.Sprintf(`
data "nsxt_policy_site" "test" {
display_name = "%s"
}
data "nsxt_policy_edge_cluster" "test" {
site_path = data.nsxt_policy_site.test.path
}`, getTestSiteName())
}