Skip to content

Commit

Permalink
Add test cases for JSON resource marshaling (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayalideshmukh10 authored Oct 25, 2022
1 parent 33c3e88 commit dfd7737
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions github/scim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,3 +464,79 @@ func TestSCIMUserName_Marshal(t *testing.T) {
}`
testJSONMarshal(t, u, want)
}

func TestSCIMMeta_Marshal(t *testing.T) {
testJSONMarshal(t, &SCIMMeta{}, `{}`)

u := &SCIMMeta{
ResourceType: String("test"),
Location: String("test"),
}

want := `{
"resourceType": "test",
"location": "test"
}`

testJSONMarshal(t, u, want)
}

func TestSCIMProvisionedIdentities_Marshal(t *testing.T) {
testJSONMarshal(t, &SCIMProvisionedIdentities{}, `{}`)

u := &SCIMProvisionedIdentities{
Schemas: []string{"test", "schema"},
TotalResults: Int(1),
ItemsPerPage: Int(2),
StartIndex: Int(1),
Resources: []*SCIMUserAttributes{
{
UserName: "SCIM",
Name: SCIMUserName{
GivenName: "scim",
FamilyName: "test",
Formatted: String("SCIM"),
},
DisplayName: String("Test SCIM"),
Emails: []*SCIMUserEmail{
{
Value: "test",
Primary: Bool(true),
Type: String("test"),
},
},
Schemas: []string{"schema1"},
ExternalID: String("id"),
Groups: []string{"group1"},
Active: Bool(true),
},
},
}

want := `{
"schemas": ["test", "schema"],
"totalResults": 1,
"itemsPerPage": 2,
"startIndex": 1,
"Resources": [{
"userName": "SCIM",
"name": {
"givenName": "scim",
"familyName": "test",
"formatted": "SCIM"
},
"displayName": "Test SCIM",
"emails": [{
"value": "test",
"primary": true,
"type": "test"
}],
"schemas": ["schema1"],
"externalId": "id",
"groups": ["group1"],
"active": true
}]
}`

testJSONMarshal(t, u, want)
}

0 comments on commit dfd7737

Please sign in to comment.