-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathstructure_machine_config_v2_linode_test.go
More file actions
129 lines (120 loc) · 4.71 KB
/
structure_machine_config_v2_linode_test.go
File metadata and controls
129 lines (120 loc) · 4.71 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package rancher2
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFlattenMachineConfigV2Linode(t *testing.T) {
input := &MachineConfigV2Linode{
machineConfigV2Linode: machineConfigV2Linode{
AuthorizedUsers: "user1,user2",
CreatePrivateIP: false,
DockerPort: "2377",
Image: "linode/ubuntu22.04",
InstanceType: "g6-standard-2",
Label: "example",
Region: "us-east",
RootPass: "secret",
SSHPort: "2222",
SSHUser: "ubuntu",
StackScript: "user/stack",
StackscriptData: "{\"foo\":\"bar\"}",
UserData: "#cloud-config\npackages:\n- htop\n",
SwapSize: "256",
Tags: "tag1,tag2",
Token: "token",
UAPrefix: "tf-provider/1.0",
UseInterfaces: true,
VPCSubnetID: "456",
VPCPrivateIP: "10.0.0.10",
PublicInterfaceFirewallID: "789",
VPCInterfaceFirewallID: "321",
},
}
expected := []interface{}{
map[string]interface{}{
"authorized_users": "user1,user2",
"create_private_ip": false,
"docker_port": "2377",
"image": "linode/ubuntu22.04",
"instance_type": "g6-standard-2",
"label": "example",
"region": "us-east",
"root_pass": "secret",
"ssh_port": "2222",
"ssh_user": "ubuntu",
"stackscript": "user/stack",
"stackscript_data": "{\"foo\":\"bar\"}",
"user_data": "#cloud-config\npackages:\n- htop\n",
"swap_size": "256",
"tags": "tag1,tag2",
"token": "token",
"use_interfaces": true,
"vpc_subnet_id": "456",
"vpc_private_ip": "10.0.0.10",
"public_interface_firewall_id": "789",
"vpc_interface_firewall_id": "321",
"ua_prefix": "tf-provider/1.0",
},
}
assert.Equal(t, expected, flattenMachineConfigV2Linode(input))
}
func TestExpandMachineConfigV2Linode(t *testing.T) {
input := []interface{}{
map[string]interface{}{
"authorized_users": "user1,user2",
"create_private_ip": false,
"docker_port": "2377",
"image": "linode/ubuntu22.04",
"instance_type": "g6-standard-2",
"label": "example",
"region": "us-east",
"root_pass": "secret",
"ssh_port": "2222",
"ssh_user": "ubuntu",
"stackscript": "user/stack",
"stackscript_data": "{\"foo\":\"bar\"}",
"user_data": "#cloud-config\npackages:\n- htop\n",
"swap_size": "256",
"tags": "tag1,tag2",
"token": "token",
"use_interfaces": true,
"vpc_subnet_id": "456",
"vpc_private_ip": "10.0.0.10",
"public_interface_firewall_id": "789",
"vpc_interface_firewall_id": "321",
"ua_prefix": "tf-provider/1.0",
},
}
source := &MachineConfigV2{}
got := expandMachineConfigV2Linode(input, source)
expected := &MachineConfigV2Linode{
machineConfigV2Linode: machineConfigV2Linode{
AuthorizedUsers: "user1,user2",
CreatePrivateIP: false,
DockerPort: "2377",
Image: "linode/ubuntu22.04",
InstanceType: "g6-standard-2",
Label: "example",
Region: "us-east",
RootPass: "secret",
SSHPort: "2222",
SSHUser: "ubuntu",
StackScript: "user/stack",
StackscriptData: "{\"foo\":\"bar\"}",
UserData: "#cloud-config\npackages:\n- htop\n",
SwapSize: "256",
Tags: "tag1,tag2",
Token: "token",
UAPrefix: "tf-provider/1.0",
UseInterfaces: true,
VPCSubnetID: "456",
VPCPrivateIP: "10.0.0.10",
PublicInterfaceFirewallID: "789",
VPCInterfaceFirewallID: "321",
},
}
expected.TypeMeta.Kind = machineConfigV2LinodeKind
expected.TypeMeta.APIVersion = machineConfigV2LinodeAPIVersion
assert.Equal(t, expected, got)
assert.Equal(t, expected.TypeMeta, source.TypeMeta)
}