Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for JSON resource marshaling #2532

Merged
merged 1 commit into from Oct 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 43 additions & 1 deletion github/teams_discussions_test.go
Expand Up @@ -562,6 +562,27 @@ func TestTeamDiscussion_Marshal(t *testing.T) {
CommentsURL: String("https://api.github.com/teams/2/discussions/3/comments"),
CreatedAt: &Timestamp{referenceTime},
LastEditedAt: &Timestamp{referenceTime},
HTMLURL: String("https://api.github.com/teams/2/discussions/3/comments"),
NodeID: String("A123"),
Number: Int(10),
Pinned: Bool(true),
Private: Bool(false),
TeamURL: String("https://api.github.com/teams/2/discussions/3/comments"),
Title: String("Test"),
UpdatedAt: &Timestamp{referenceTime},
URL: String("https://api.github.com/teams/2/discussions/3/comments"),
Reactions: &Reactions{
TotalCount: Int(1),
PlusOne: Int(2),
MinusOne: Int(-3),
Laugh: Int(4),
Confused: Int(5),
Heart: Int(6),
Hooray: Int(7),
Rocket: Int(8),
Eyes: Int(9),
URL: String("https://api.github.com/teams/2/discussions/3/comments"),
},
}

want := `{
Expand All @@ -580,7 +601,28 @@ func TestTeamDiscussion_Marshal(t *testing.T) {
"comments_count": 1,
"comments_url": "https://api.github.com/teams/2/discussions/3/comments",
"created_at": ` + referenceTimeStr + `,
"last_edited_at": ` + referenceTimeStr + `
"last_edited_at": ` + referenceTimeStr + `,
"html_url": "https://api.github.com/teams/2/discussions/3/comments",
"node_id": "A123",
"number": 10,
"pinned": true,
"private": false,
"team_url": "https://api.github.com/teams/2/discussions/3/comments",
"title": "Test",
"updated_at": ` + referenceTimeStr + `,
"url": "https://api.github.com/teams/2/discussions/3/comments",
"reactions": {
"total_count": 1,
"+1": 2,
"-1": -3,
"laugh": 4,
"confused": 5,
"heart": 6,
"hooray": 7,
"rocket": 8,
"eyes": 9,
"url": "https://api.github.com/teams/2/discussions/3/comments"
}
}`

testJSONMarshal(t, u, want)
Expand Down