Skip to content

Commit 3bb7306

Browse files
committed
Resources Covered :
- Issue - IssueRequest - PullRequestLinks - LockIssueOptions
1 parent f47f8fe commit 3bb7306

File tree

1 file changed

+160
-0
lines changed

1 file changed

+160
-0
lines changed

github/issues_test.go

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,163 @@ func TestIsPullRequest(t *testing.T) {
433433
t.Errorf("expected i.IsPullRequest (%v) to return true, got false", i)
434434
}
435435
}
436+
437+
func TestLockIssueOptions_Marshal(t *testing.T) {
438+
testJSONMarshal(t, &LockIssueOptions{}, "{}")
439+
440+
u := &LockIssueOptions{
441+
LockReason: "lr",
442+
}
443+
444+
want := `{
445+
"lock_reason": "lr"
446+
}`
447+
448+
testJSONMarshal(t, u, want)
449+
}
450+
451+
func TestPullRequestLinks_Marshal(t *testing.T) {
452+
testJSONMarshal(t, &PullRequestLinks{}, "{}")
453+
454+
u := &PullRequestLinks{
455+
URL: String("url"),
456+
HTMLURL: String("hurl"),
457+
DiffURL: String("durl"),
458+
PatchURL: String("purl"),
459+
}
460+
461+
want := `{
462+
"url": "url",
463+
"html_url": "hurl",
464+
"diff_url": "durl",
465+
"patch_url": "purl"
466+
}`
467+
468+
testJSONMarshal(t, u, want)
469+
}
470+
471+
func TestIssueRequest_Marshal(t *testing.T) {
472+
testJSONMarshal(t, &IssueRequest{}, "{}")
473+
474+
u := &IssueRequest{
475+
Title: String("url"),
476+
Body: String("url"),
477+
Labels: &[]string{"l"},
478+
Assignee: String("url"),
479+
State: String("url"),
480+
Milestone: Int(1),
481+
Assignees: &[]string{"a"},
482+
}
483+
484+
want := `{
485+
"title": "url",
486+
"body": "url",
487+
"labels": [
488+
"l"
489+
],
490+
"assignee": "url",
491+
"state": "url",
492+
"milestone": 1,
493+
"assignees": [
494+
"a"
495+
]
496+
}`
497+
498+
testJSONMarshal(t, u, want)
499+
}
500+
501+
func TestIssue_Marshal(t *testing.T) {
502+
testJSONMarshal(t, &Issue{}, "{}")
503+
504+
u := &Issue{
505+
ID: Int64(1),
506+
Number: Int(1),
507+
State: String("s"),
508+
Locked: Bool(false),
509+
Title: String("title"),
510+
Body: String("body"),
511+
AuthorAssociation: String("aa"),
512+
User: &User{ID: Int64(1)},
513+
Labels: []*Label{{ID: Int64(1)}},
514+
Assignee: &User{ID: Int64(1)},
515+
Comments: Int(1),
516+
ClosedAt: &referenceTime,
517+
CreatedAt: &referenceTime,
518+
UpdatedAt: &referenceTime,
519+
ClosedBy: &User{ID: Int64(1)},
520+
URL: String("url"),
521+
HTMLURL: String("hurl"),
522+
CommentsURL: String("curl"),
523+
EventsURL: String("eurl"),
524+
LabelsURL: String("lurl"),
525+
RepositoryURL: String("rurl"),
526+
Milestone: &Milestone{ID: Int64(1)},
527+
PullRequestLinks: &PullRequestLinks{URL: String("url")},
528+
Repository: &Repository{ID: Int64(1)},
529+
Reactions: &Reactions{TotalCount: Int(1)},
530+
Assignees: []*User{{ID: Int64(1)}},
531+
NodeID: String("nid"),
532+
TextMatches: []*TextMatch{{ObjectURL: String("ourl")}},
533+
ActiveLockReason: String("alr"),
534+
}
535+
536+
want := `{
537+
"id": 1,
538+
"number": 1,
539+
"state": "s",
540+
"locked": false,
541+
"title": "title",
542+
"body": "body",
543+
"author_association": "aa",
544+
"user": {
545+
"id": 1
546+
},
547+
"labels": [
548+
{
549+
"id": 1
550+
}
551+
],
552+
"assignee": {
553+
"id": 1
554+
},
555+
"comments": 1,
556+
"closed_at": ` + referenceTimeStr + `,
557+
"created_at": ` + referenceTimeStr + `,
558+
"updated_at": ` + referenceTimeStr + `,
559+
"closed_by": {
560+
"id": 1
561+
},
562+
"url": "url",
563+
"html_url": "hurl",
564+
"comments_url": "curl",
565+
"events_url": "eurl",
566+
"labels_url": "lurl",
567+
"repository_url": "rurl",
568+
"milestone": {
569+
"id": 1
570+
},
571+
"pull_request": {
572+
"url": "url"
573+
},
574+
"repository": {
575+
"id": 1
576+
},
577+
"reactions": {
578+
"total_count": 1
579+
},
580+
"assignees": [
581+
{
582+
"id": 1
583+
}
584+
],
585+
"node_id": "nid",
586+
"text_matches": [
587+
{
588+
"object_url": "ourl"
589+
}
590+
],
591+
"active_lock_reason": "alr"
592+
}`
593+
594+
testJSONMarshal(t, u, want)
595+
}

0 commit comments

Comments
 (0)