-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathcluster_spec_flatten_test.go
More file actions
79 lines (72 loc) · 2.03 KB
/
Copy pathcluster_spec_flatten_test.go
File metadata and controls
79 lines (72 loc) · 2.03 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: MPL-2.0
package cluster
import (
"testing"
"github.com/stretchr/testify/require"
clustermodel "github.com/vmware/terraform-provider-tanzu-mission-control/internal/models/cluster"
)
func TestFlattenSpec(t *testing.T) {
t.Parallel()
cases := []struct {
description string
input *clustermodel.VmwareTanzuManageV1alpha1ClusterSpec
expected []interface{}
}{
{
description: "check for nil data in cluster spec",
input: nil,
expected: nil,
},
{
description: "normal scenario with cluster group",
input: &clustermodel.VmwareTanzuManageV1alpha1ClusterSpec{
ClusterGroupName: clusterGroupDefaultValue,
},
expected: []interface{}{
map[string]interface{}{
clusterGroupKey: clusterGroupDefaultValue,
proxyNameKey: "",
imageRegistryNameKey: "",
},
},
},
{
description: "normal scenario with cluster group and proxy",
input: &clustermodel.VmwareTanzuManageV1alpha1ClusterSpec{
ClusterGroupName: clusterGroupDefaultValue,
ProxyName: proxyNameKey,
},
expected: []interface{}{
map[string]interface{}{
clusterGroupKey: clusterGroupDefaultValue,
proxyNameKey: proxyNameKey,
imageRegistryNameKey: "",
},
},
},
{
description: "normal scenario with cluster group, proxy and image registry",
input: &clustermodel.VmwareTanzuManageV1alpha1ClusterSpec{
ClusterGroupName: clusterGroupDefaultValue,
ProxyName: proxyNameKey,
ImageRegistry: "image-registry",
},
expected: []interface{}{
map[string]interface{}{
clusterGroupKey: clusterGroupDefaultValue,
proxyNameKey: proxyNameKey,
imageRegistryNameKey: "image-registry",
},
},
},
}
for _, each := range cases {
test := each
t.Run(test.description, func(t *testing.T) {
actual := flattenSpec(test.input)
require.Equal(t, test.expected, actual)
})
}
}