Skip to content

Commit da6c8ac

Browse files
committed
Resources Covered :
- PullRequestReview - PullRequestReviewRequest - DraftReviewComment - PullRequestReviewDismissalRequest
1 parent babe748 commit da6c8ac

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

github/pulls_reviews_test.go

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,3 +629,155 @@ func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) {
629629
_, _, err := client.PullRequests.DismissReview(ctx, "%", "r", 1, 1, &PullRequestReviewDismissalRequest{})
630630
testURLParseError(t, err)
631631
}
632+
633+
func TestPullRequestReviewDismissalRequest_Marshal(t *testing.T) {
634+
testJSONMarshal(t, &PullRequestReviewDismissalRequest{}, "{}")
635+
636+
u := &PullRequestReviewDismissalRequest{
637+
Message: String("msg"),
638+
}
639+
640+
want := `{
641+
"message": "msg"
642+
}`
643+
644+
testJSONMarshal(t, u, want)
645+
}
646+
647+
func TestDraftReviewComment_Marshal(t *testing.T) {
648+
testJSONMarshal(t, &DraftReviewComment{}, "{}")
649+
650+
u := &DraftReviewComment{
651+
Path: String("path"),
652+
Position: Int(1),
653+
Body: String("body"),
654+
StartSide: String("ss"),
655+
Side: String("side"),
656+
StartLine: Int(1),
657+
Line: Int(1),
658+
}
659+
660+
want := `{
661+
"path": "path",
662+
"position": 1,
663+
"body": "body",
664+
"start_side": "ss",
665+
"side": "side",
666+
"start_line": 1,
667+
"line": 1
668+
}`
669+
670+
testJSONMarshal(t, u, want)
671+
}
672+
673+
func TestPullRequestReviewRequest_Marshal(t *testing.T) {
674+
testJSONMarshal(t, &PullRequestReviewRequest{}, "{}")
675+
676+
u := &PullRequestReviewRequest{
677+
NodeID: String("nodeid"),
678+
CommitID: String("cid"),
679+
Body: String("body"),
680+
Event: String("event"),
681+
Comments: []*DraftReviewComment{
682+
{
683+
Path: String("path"),
684+
Position: Int(1),
685+
Body: String("body"),
686+
StartSide: String("ss"),
687+
Side: String("side"),
688+
StartLine: Int(1),
689+
Line: Int(1),
690+
},
691+
},
692+
}
693+
694+
want := `{
695+
"node_id": "nodeid",
696+
"commit_id": "cid",
697+
"body": "body",
698+
"event": "event",
699+
"comments": [
700+
{
701+
"path": "path",
702+
"position": 1,
703+
"body": "body",
704+
"start_side": "ss",
705+
"side": "side",
706+
"start_line": 1,
707+
"line": 1
708+
}
709+
]
710+
}`
711+
712+
testJSONMarshal(t, u, want)
713+
}
714+
715+
func TestPullRequestReview_Marshal(t *testing.T) {
716+
testJSONMarshal(t, &PullRequestReview{}, "{}")
717+
718+
u := &PullRequestReview{
719+
ID: Int64(1),
720+
NodeID: String("nid"),
721+
User: &User{
722+
Login: String("l"),
723+
ID: Int64(1),
724+
URL: String("u"),
725+
AvatarURL: String("a"),
726+
GravatarID: String("g"),
727+
Name: String("n"),
728+
Company: String("c"),
729+
Blog: String("b"),
730+
Location: String("l"),
731+
Email: String("e"),
732+
Hireable: Bool(true),
733+
Bio: String("b"),
734+
TwitterUsername: String("t"),
735+
PublicRepos: Int(1),
736+
Followers: Int(1),
737+
Following: Int(1),
738+
CreatedAt: &Timestamp{referenceTime},
739+
SuspendedAt: &Timestamp{referenceTime},
740+
},
741+
Body: String("body"),
742+
SubmittedAt: &referenceTime,
743+
CommitID: String("cid"),
744+
HTMLURL: String("hurl"),
745+
PullRequestURL: String("prurl"),
746+
State: String("state"),
747+
AuthorAssociation: String("aa"),
748+
}
749+
750+
want := `{
751+
"id": 1,
752+
"node_id": "nid",
753+
"user": {
754+
"login": "l",
755+
"id": 1,
756+
"avatar_url": "a",
757+
"gravatar_id": "g",
758+
"name": "n",
759+
"company": "c",
760+
"blog": "b",
761+
"location": "l",
762+
"email": "e",
763+
"hireable": true,
764+
"bio": "b",
765+
"twitter_username": "t",
766+
"public_repos": 1,
767+
"followers": 1,
768+
"following": 1,
769+
"created_at": ` + referenceTimeStr + `,
770+
"suspended_at": ` + referenceTimeStr + `,
771+
"url": "u"
772+
},
773+
"body": "body",
774+
"submitted_at": ` + referenceTimeStr + `,
775+
"commit_id": "cid",
776+
"html_url": "hurl",
777+
"pull_request_url": "prurl",
778+
"state": "state",
779+
"author_association": "aa"
780+
}`
781+
782+
testJSONMarshal(t, u, want)
783+
}

0 commit comments

Comments
 (0)