@@ -22,8 +22,20 @@ func TestToCtyValue(t *testing.T) {
2222 },
2323 }
2424
25- _ , err := owner .ToCtyValue ()
25+ ownerValue , err := owner .ToCtyValue ()
2626 require .NoError (t , err )
27+
28+ require .Equal (t , owner .ID .String (), ownerValue .AsValueMap ()["id" ].AsString ())
29+ require .Equal (t , owner .Name , ownerValue .AsValueMap ()["name" ].AsString ())
30+ require .Equal (t , owner .SSHPublicKey , ownerValue .AsValueMap ()["ssh_public_key" ].AsString ())
31+ for i , it := range owner .Groups {
32+ require .Equal (t , it , ownerValue .AsValueMap ()["groups" ].AsValueSlice ()[i ].AsString ())
33+ }
34+ for i , it := range owner .RBACRoles {
35+ roleValueMap := ownerValue .AsValueMap ()["rbac_roles" ].AsValueSlice ()[i ].AsValueMap ()
36+ require .Equal (t , it .Name , roleValueMap ["name" ].AsString ())
37+ require .Equal (t , it .OrgID .String (), roleValueMap ["org_id" ].AsString ())
38+ }
2739}
2840
2941func TestToCtyValueWithNilLists (t * testing.T ) {
@@ -38,6 +50,8 @@ func TestToCtyValueWithNilLists(t *testing.T) {
3850 RBACRoles : nil ,
3951 }
4052
41- _ , err := owner .ToCtyValue ()
53+ ownerValue , err := owner .ToCtyValue ()
4254 require .NoError (t , err )
55+ require .Empty (t , ownerValue .AsValueMap ()["groups" ].AsValueSlice ())
56+ require .Empty (t , ownerValue .AsValueMap ()["rbac_roles" ].AsValueSlice ())
4357}
0 commit comments