-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathstructure_identity_test.go
82 lines (78 loc) · 1.98 KB
/
structure_identity_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
76
77
78
79
80
81
82
package main
import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
reflect "reflect"
"testing"
)
var (
testIdentityConf *Identity
testIdentityInterface map[string]interface{}
)
func init() {
testIdentityConf = &Identity{
Alias: "test_alias",
Name: "Test Name",
Description: "test description",
EmailAddress: "[email protected]",
IdentityStatus: "ACTIVE",
Enabled: true,
IsManager: false,
IdentityAttributes: &IdentityAttributes{
AdpID: "12345",
LastName: "Name",
FirstName: "Test",
Phone: "+11234567890",
UserType: "Employee",
UID: "tname",
Email: "[email protected]",
WorkdayId: "567890",
},
}
testIdentityInterface = map[string]interface{}{
"alias": "test_alias",
"name": "Test Name",
"description": "test description",
"email_address": "[email protected]",
"identity_status": "ACTIVE",
"enabled": true,
"is_manager": false,
"attributes": []interface{}{
map[string]interface{}{
"adp_id": "12345",
"lastname": "Name",
"firstname": "Test",
"phone": "11234567890",
"user_type": "Employee",
"uid": "tname",
"email": "[email protected]",
"workday_id": "567890",
},
},
}
}
func TestFlattenIdentity(t *testing.T) {
cases := []struct {
Input *Identity
ExpectedOutput map[string]interface{}
}{
{
testIdentityConf,
testIdentityInterface,
},
}
for _, tc := range cases {
output := schema.TestResourceDataRaw(t, identityFields(), tc.ExpectedOutput)
err := flattenIdentity(output, tc.Input)
if err != nil {
t.Fatalf("[ERROR] on flattener: %#v", err)
}
expectedOutput := map[string]interface{}{}
for k := range tc.ExpectedOutput {
expectedOutput[k] = output.Get(k)
}
if !reflect.DeepEqual(expectedOutput, tc.ExpectedOutput) {
t.Fatalf("Unexpected output from flattener.\nExpected: %#v\nGiven: %#v",
tc.ExpectedOutput, expectedOutput)
}
}
}