-
Notifications
You must be signed in to change notification settings - Fork 7
/
structure_source_forest_settings_test.go
75 lines (67 loc) · 1.69 KB
/
structure_source_forest_settings_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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package main
import (
"reflect"
"testing"
)
var (
testForestSettingsConf []*ForestSettings
testForestSettingsInterface []interface{}
)
func init() {
testForestSettingsConf = []*ForestSettings{
{
Password: "test-password",
ForestName: "test-forest-name",
GcServer: "test1-server.com:1234",
User: "test-user",
UseSSL: true,
AuthorizationType: "test-authorization-type",
},
}
testForestSettingsInterface = []interface{}{
map[string]interface{}{
"password": "test-password",
"forest_name": "test-forest-name",
"gc_server": "test1-server.com:1234",
"user": "test-user",
"use_ssl": true,
"authorization_type": "test-authorization-type",
},
}
}
func TestFlattenSourceForestSettings(t *testing.T) {
cases := []struct {
Input []*ForestSettings
ExpectedOutput []interface{}
}{
{
testForestSettingsConf,
testForestSettingsInterface,
},
}
for _, tc := range cases {
output := flattenSourceForestSettings(tc.Input)
if !reflect.DeepEqual(output, tc.ExpectedOutput) {
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v",
tc.ExpectedOutput, output)
}
}
}
func TestExpandSourceForestSettings(t *testing.T) {
cases := []struct {
Input []interface{}
ExpectedOutput []*ForestSettings
}{
{
testForestSettingsInterface,
testForestSettingsConf,
},
}
for _, tc := range cases {
output := expandSourceForestSettings(tc.Input)
if !reflect.DeepEqual(output, tc.ExpectedOutput) {
t.Fatalf("Unexpected output from expander.\nExpected: %#v\nGiven: %#v",
tc.ExpectedOutput, output)
}
}
}