Skip to content

Commit

Permalink
Add test case for JSON resource marshaling (#2541)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkarmore committed Oct 28, 2022
1 parent cb9253a commit 81b88b0
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions github/teams_test.go
Expand Up @@ -2155,6 +2155,60 @@ func TestExternalGroupMember_Marshal(t *testing.T) {
testJSONMarshal(t, u, want)
}

func TestExternalGroup_Marshal(t *testing.T) {
testJSONMarshal(t, &ExternalGroup{}, "{}")

u := &ExternalGroup{
GroupID: Int64(123),
GroupName: String("group1"),
UpdatedAt: &Timestamp{referenceTime},
Teams: []*ExternalGroupTeam{
{
TeamID: Int64(1),
TeamName: String("team-test"),
},
{
TeamID: Int64(2),
TeamName: String("team-test2"),
},
},
Members: []*ExternalGroupMember{
{
MemberID: Int64(1),
MemberLogin: String("test"),
MemberName: String("test"),
MemberEmail: String("test@github.com"),
},
},
}

want := `{
"group_id": 123,
"group_name": "group1",
"updated_at": ` + referenceTimeStr + `,
"teams": [
{
"team_id": 1,
"team_name": "team-test"
},
{
"team_id": 2,
"team_name": "team-test2"
}
],
"members": [
{
"member_id": 1,
"member_login": "test",
"member_name": "test",
"member_email": "test@github.com"
}
]
}`

testJSONMarshal(t, u, want)
}

func TestExternalGroupTeam_Marshal(t *testing.T) {
testJSONMarshal(t, &ExternalGroupTeam{}, "{}")

Expand Down

0 comments on commit 81b88b0

Please sign in to comment.