@@ -479,3 +479,320 @@ func TestChecksService_ReRequestCheckSuite(t *testing.T) {
479479 t .Errorf ("Checks.ReRequestCheckSuite = %v, want %v" , got , want )
480480 }
481481}
482+
483+ func Test_CheckRunMarshal (t * testing.T ) {
484+ testJSONMarshal (t , & CheckRun {}, "{}" )
485+
486+ now := time .Now ()
487+ ts := now .Format (time .RFC3339Nano )
488+
489+ c := CheckRun {
490+ ID : Int64 (1 ),
491+ NodeID : String ("n" ),
492+ HeadSHA : String ("h" ),
493+ ExternalID : String ("1" ),
494+ URL : String ("u" ),
495+ HTMLURL : String ("u" ),
496+ DetailsURL : String ("u" ),
497+ Status : String ("s" ),
498+ Conclusion : String ("c" ),
499+ StartedAt : & Timestamp {Time : now },
500+ CompletedAt : & Timestamp {Time : now },
501+ Output : & CheckRunOutput {
502+ Annotations : []* CheckRunAnnotation {
503+ {
504+ AnnotationLevel : String ("a" ),
505+ BlobHRef : String ("b" ),
506+ EndLine : Int (1 ),
507+ Message : String ("m" ),
508+ Path : String ("p" ),
509+ RawDetails : String ("r" ),
510+ StartLine : Int (1 ),
511+ Title : String ("t" ),
512+ },
513+ },
514+ AnnotationsCount : Int (1 ),
515+ AnnotationsURL : String ("a" ),
516+ Images : []* CheckRunImage {
517+ {
518+ Alt : String ("a" ),
519+ ImageURL : String ("i" ),
520+ Caption : String ("c" ),
521+ },
522+ },
523+ Title : String ("t" ),
524+ Summary : String ("s" ),
525+ Text : String ("t" ),
526+ },
527+ Name : String ("n" ),
528+ CheckSuite : & CheckSuite {
529+ ID : Int64 (1 ),
530+ },
531+ App : & App {
532+ ID : Int64 (1 ),
533+ NodeID : String ("n" ),
534+ Owner : & User {
535+ Login : String ("l" ),
536+ ID : Int64 (1 ),
537+ NodeID : String ("n" ),
538+ URL : String ("u" ),
539+ ReposURL : String ("r" ),
540+ EventsURL : String ("e" ),
541+ AvatarURL : String ("a" ),
542+ },
543+ Name : String ("n" ),
544+ Description : String ("d" ),
545+ HTMLURL : String ("h" ),
546+ ExternalURL : String ("u" ),
547+ CreatedAt : & now ,
548+ UpdatedAt : & now ,
549+ },
550+ PullRequests : []* PullRequest {
551+ {
552+ URL : String ("u" ),
553+ ID : Int64 (1 ),
554+ Number : Int (1 ),
555+ Head : & PullRequestBranch {
556+ Ref : String ("r" ),
557+ SHA : String ("s" ),
558+ Repo : & Repository {
559+ ID : Int64 (1 ),
560+ URL : String ("s" ),
561+ Name : String ("n" ),
562+ },
563+ },
564+ Base : & PullRequestBranch {
565+ Ref : String ("r" ),
566+ SHA : String ("s" ),
567+ Repo : & Repository {
568+ ID : Int64 (1 ),
569+ URL : String ("u" ),
570+ Name : String ("n" ),
571+ },
572+ },
573+ },
574+ },
575+ }
576+ w := fmt .Sprintf (`{
577+ "id": 1,
578+ "node_id": "n",
579+ "head_sha": "h",
580+ "external_id": "1",
581+ "url": "u",
582+ "html_url": "u",
583+ "details_url": "u",
584+ "status": "s",
585+ "conclusion": "c",
586+ "started_at": "%s",
587+ "completed_at": "%s",
588+ "output": {
589+ "title": "t",
590+ "summary": "s",
591+ "text": "t",
592+ "annotations_count": 1,
593+ "annotations_url": "a",
594+ "annotations": [
595+ {
596+ "path": "p",
597+ "blob_href": "b",
598+ "start_line": 1,
599+ "end_line": 1,
600+ "annotation_level": "a",
601+ "message": "m",
602+ "title": "t",
603+ "raw_details": "r"
604+ }
605+ ],
606+ "images": [
607+ {
608+ "alt": "a",
609+ "image_url": "i",
610+ "caption": "c"
611+ }
612+ ]
613+ },
614+ "name": "n",
615+ "check_suite": {
616+ "id": 1
617+ },
618+ "app": {
619+ "id": 1,
620+ "node_id": "n",
621+ "owner": {
622+ "login": "l",
623+ "id": 1,
624+ "node_id": "n",
625+ "avatar_url": "a",
626+ "url": "u",
627+ "events_url": "e",
628+ "repos_url": "r"
629+ },
630+ "name": "n",
631+ "description": "d",
632+ "external_url": "u",
633+ "html_url": "h",
634+ "created_at": "%s",
635+ "updated_at": "%s"
636+ },
637+ "pull_requests": [
638+ {
639+ "id": 1,
640+ "number": 1,
641+ "url": "u",
642+ "head": {
643+ "ref": "r",
644+ "sha": "s",
645+ "repo": {
646+ "id": 1,
647+ "name": "n",
648+ "url": "s"
649+ }
650+ },
651+ "base": {
652+ "ref": "r",
653+ "sha": "s",
654+ "repo": {
655+ "id": 1,
656+ "name": "n",
657+ "url": "u"
658+ }
659+ }
660+ }
661+ ]
662+ }` , ts , ts , ts , ts )
663+
664+ testJSONMarshal (t , & c , w )
665+ }
666+
667+ func Test_CheckSuiteMarshal (t * testing.T ) {
668+ testJSONMarshal (t , & CheckSuite {}, "{}" )
669+
670+ now := time .Now ()
671+ ts := now .Format (time .RFC3339Nano )
672+
673+ c := CheckSuite {
674+ ID : Int64 (1 ),
675+ NodeID : String ("n" ),
676+ HeadBranch : String ("h" ),
677+ HeadSHA : String ("h" ),
678+ URL : String ("u" ),
679+ BeforeSHA : String ("b" ),
680+ AfterSHA : String ("a" ),
681+ Status : String ("s" ),
682+ Conclusion : String ("c" ),
683+ App : & App {
684+ ID : Int64 (1 ),
685+ NodeID : String ("n" ),
686+ Owner : & User {
687+ Login : String ("l" ),
688+ ID : Int64 (1 ),
689+ NodeID : String ("n" ),
690+ URL : String ("u" ),
691+ ReposURL : String ("r" ),
692+ EventsURL : String ("e" ),
693+ AvatarURL : String ("a" ),
694+ },
695+ Name : String ("n" ),
696+ Description : String ("d" ),
697+ HTMLURL : String ("h" ),
698+ ExternalURL : String ("u" ),
699+ CreatedAt : & now ,
700+ UpdatedAt : & now ,
701+ },
702+ Repository : & Repository {
703+ ID : Int64 (1 ),
704+ },
705+ PullRequests : []* PullRequest {
706+ {
707+ URL : String ("u" ),
708+ ID : Int64 (1 ),
709+ Number : Int (1 ),
710+ Head : & PullRequestBranch {
711+ Ref : String ("r" ),
712+ SHA : String ("s" ),
713+ Repo : & Repository {
714+ ID : Int64 (1 ),
715+ URL : String ("s" ),
716+ Name : String ("n" ),
717+ },
718+ },
719+ Base : & PullRequestBranch {
720+ Ref : String ("r" ),
721+ SHA : String ("s" ),
722+ Repo : & Repository {
723+ ID : Int64 (1 ),
724+ URL : String ("u" ),
725+ Name : String ("n" ),
726+ },
727+ },
728+ },
729+ },
730+ HeadCommit : & Commit {
731+ SHA : String ("s" ),
732+ },
733+ }
734+
735+ w := fmt .Sprintf (`{
736+ "id": 1,
737+ "node_id": "n",
738+ "head_branch": "h",
739+ "head_sha": "h",
740+ "url": "u",
741+ "before": "b",
742+ "after": "a",
743+ "status": "s",
744+ "conclusion": "c",
745+ "app": {
746+ "id": 1,
747+ "node_id": "n",
748+ "owner": {
749+ "login": "l",
750+ "id": 1,
751+ "node_id": "n",
752+ "avatar_url": "a",
753+ "url": "u",
754+ "events_url": "e",
755+ "repos_url": "r"
756+ },
757+ "name": "n",
758+ "description": "d",
759+ "external_url": "u",
760+ "html_url": "h",
761+ "created_at": "%s",
762+ "updated_at": "%s"
763+ },
764+ "repository": {
765+ "id": 1
766+ },
767+ "pull_requests": [
768+ {
769+ "id": 1,
770+ "number": 1,
771+ "url": "u",
772+ "head": {
773+ "ref": "r",
774+ "sha": "s",
775+ "repo": {
776+ "id": 1,
777+ "name": "n",
778+ "url": "s"
779+ }
780+ },
781+ "base": {
782+ "ref": "r",
783+ "sha": "s",
784+ "repo": {
785+ "id": 1,
786+ "name": "n",
787+ "url": "u"
788+ }
789+ }
790+ }
791+ ],
792+ "head_commit": {
793+ "sha": "s"
794+ }
795+ }` , ts , ts )
796+
797+ testJSONMarshal (t , & c , w )
798+ }
0 commit comments