-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathdata_source_cluster_test.go
More file actions
59 lines (47 loc) · 1.81 KB
/
Copy pathdata_source_cluster_test.go
File metadata and controls
59 lines (47 loc) · 1.81 KB
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
//go:build cluster
// © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: MPL-2.0
package cluster
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
testhelper "github.com/vmware/terraform-provider-tanzu-mission-control/internal/resources/testing"
)
func TestAcceptanceForAttachClusterDataSource(t *testing.T) {
var provider = initTestProvider(t)
resource.Test(t, resource.TestCase{
PreCheck: testhelper.TestPreCheck(t),
ProviderFactories: testhelper.GetTestProviderFactories(provider),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: testGetResourceClusterDefinition(t, testhelper.WithClusterName("tf-attach-test-ds"), testhelper.WithDataSourceScript()),
Check: resource.ComposeTestCheckFunc(
checkDataSourceAttributes(),
),
},
},
})
t.Log("cluster data source acceptance test complete!")
}
func checkDataSourceAttributes() resource.TestCheckFunc {
var check = []resource.TestCheckFunc{
verifyClusterDataSource(testhelper.ClusterDataSourceName),
resource.TestCheckResourceAttrPair(testhelper.ClusterDataSourceName, "name", testhelper.ClusterResourceName, "name"),
resource.TestCheckResourceAttrSet(testhelper.ClusterDataSourceName, "id"),
}
check = append(check, testhelper.MetaDataSourceAttributeCheck(testhelper.ClusterDataSourceName, testhelper.ClusterResourceName)...)
return resource.ComposeTestCheckFunc(check...)
}
func verifyClusterDataSource(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
_, ok := s.RootModule().Resources[name]
if !ok {
return fmt.Errorf("root module does not have cluster resource %s", name)
}
return nil
}
}