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 case for JSON resource marshaling #2543

Merged
merged 6 commits into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions github/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -914,3 +914,42 @@ func TestLabelsSearchResult_Marshal(t *testing.T) {

testJSONMarshal(t, u, want)
}

func TestCommitResult_Marshal(t *testing.T) {
gmlewis marked this conversation as resolved.
Show resolved Hide resolved
testJSONMarshal(t, &CommitResult{}, "{}")

c := &CommitResult{
SHA: String("test"),
HTMLURL: String("hurl"),
CommentsURL: String("curl"),
URL: String("url"),
Repository: &Repository{ID: Int64(1)},
Score: Float64(123),
Commit: &Commit{SHA: String("test")},
Author: &User{ID: Int64(1)},
Committer: &User{ID: Int64(1)},
Parents: []*Commit{},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for not supplying a single parent?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, let's get this in before I go OOO.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just an omitempty so I want to try to ignore this. But Thanks @gmlewis for approving :)

}

want := `{
"sha": "test",
"commit": {
"sha": "test"
},
"author": {
"id": 1
},
"committer": {
"id": 1
},
"html_url": "hurl",
"url": "url",
"comments_url": "curl",
"repository": {
"id": 1
},
"score": 123
}`

testJSONMarshal(t, c, want)
}