@@ -449,6 +449,54 @@ func TestRepositoriesService_RequestPageBuild(t *testing.T) {
449
449
})
450
450
}
451
451
452
+ func TestRepositoriesService_GetPageHealthCheck (t * testing.T ) {
453
+ client , mux , _ , teardown := setup ()
454
+ defer teardown ()
455
+
456
+ mux .HandleFunc ("/repos/o/r/pages/health" , func (w http.ResponseWriter , r * http.Request ) {
457
+ testMethod (t , r , "GET" )
458
+ fmt .Fprint (w , `{"domain":{"host":"example.com","uri":"http://example.com/","nameservers":"default","dns_resolves":true},"alt_domain":{"host":"www.example.com","uri":"http://www.example.com/","nameservers":"default","dns_resolves":true}}` )
459
+ })
460
+
461
+ ctx := context .Background ()
462
+ healthCheckResponse , _ , err := client .Repositories .GetPageHealthCheck (ctx , "o" , "r" )
463
+ if err != nil {
464
+ t .Errorf ("Repositories.GetPageHealthCheck returned error: %v" , err )
465
+ }
466
+
467
+ want := & PagesHealthCheckResponse {
468
+ Domain : & PagesDomain {
469
+ Host : String ("example.com" ),
470
+ URI : String ("http://example.com/" ),
471
+ Nameservers : String ("default" ),
472
+ DNSResolves : Bool (true ),
473
+ },
474
+ AltDomain : & PagesDomain {
475
+ Host : String ("www.example.com" ),
476
+ URI : String ("http://www.example.com/" ),
477
+ Nameservers : String ("default" ),
478
+ DNSResolves : Bool (true ),
479
+ },
480
+ }
481
+ if ! cmp .Equal (healthCheckResponse , want ) {
482
+ t .Errorf ("Repositories.GetPageHealthCheck returned %+v, want %+v" , healthCheckResponse , want )
483
+ }
484
+
485
+ const methodName = "GetPageHealthCheck"
486
+ testBadOptions (t , methodName , func () (err error ) {
487
+ _ , _ , err = client .Repositories .GetPageHealthCheck (ctx , "\n " , "\n " )
488
+ return err
489
+ })
490
+
491
+ testNewRequestAndDoFailure (t , methodName , client , func () (* Response , error ) {
492
+ got , resp , err := client .Repositories .GetPageHealthCheck (ctx , "o" , "r" )
493
+ if got != nil {
494
+ t .Errorf ("testNewRequestAndDoFailure %v = %#v, want nil" , methodName , got )
495
+ }
496
+ return resp , err
497
+ })
498
+ }
499
+
452
500
func TestPagesSource_Marshal (t * testing.T ) {
453
501
testJSONMarshal (t , & PagesSource {}, "{}" )
454
502
@@ -559,6 +607,90 @@ func TestPagesBuild_Marshal(t *testing.T) {
559
607
testJSONMarshal (t , u , want )
560
608
}
561
609
610
+ func TestPagesHealthCheckResponse_Marshal (t * testing.T ) {
611
+ testJSONMarshal (t , & PagesHealthCheckResponse {}, "{}" )
612
+
613
+ u := & PagesHealthCheckResponse {
614
+ Domain : & PagesDomain {
615
+ Host : String ("example.com" ),
616
+ URI : String ("http://example.com/" ),
617
+ Nameservers : String ("default" ),
618
+ DNSResolves : Bool (true ),
619
+ IsProxied : Bool (false ),
620
+ IsCloudflareIP : Bool (false ),
621
+ IsFastlyIP : Bool (false ),
622
+ IsOldIPAddress : Bool (false ),
623
+ IsARecord : Bool (true ),
624
+ HasCNAMERecordPresent : Bool (false ),
625
+ HasMXRecordsPresent : Bool (false ),
626
+ IsValidDomain : Bool (true ),
627
+ IsApexDomain : Bool (true ),
628
+ ShouldBeARecord : Bool (true ),
629
+ IsCNAMEToGithubUserDomain : Bool (false ),
630
+ IsCNAMEToPagesDotGithubDotCom : Bool (false ),
631
+ IsCNAMEToFastly : Bool (false ),
632
+ IsPointedToGithubPagesIP : Bool (true ),
633
+ IsNonGithubPagesIPPresent : Bool (false ),
634
+ IsPagesDomain : Bool (false ),
635
+ IsServedByPages : Bool (true ),
636
+ IsValid : Bool (true ),
637
+ Reason : String ("some reason" ),
638
+ RespondsToHTTPS : Bool (true ),
639
+ EnforcesHTTPS : Bool (true ),
640
+ HTTPSError : String ("some error" ),
641
+ IsHTTPSEligible : Bool (true ),
642
+ CAAError : String ("some error" ),
643
+ },
644
+ AltDomain : & PagesDomain {
645
+ Host : String ("www.example.com" ),
646
+ URI : String ("http://www.example.com/" ),
647
+ Nameservers : String ("default" ),
648
+ DNSResolves : Bool (true ),
649
+ },
650
+ }
651
+
652
+ want := `{
653
+ "domain": {
654
+ "host": "example.com",
655
+ "uri": "http://example.com/",
656
+ "nameservers": "default",
657
+ "dns_resolves": true,
658
+ "is_proxied": false,
659
+ "is_cloudflare_ip": false,
660
+ "is_fastly_ip": false,
661
+ "is_old_ip_address": false,
662
+ "is_a_record": true,
663
+ "has_cname_record": false,
664
+ "has_mx_records_present": false,
665
+ "is_valid_domain": true,
666
+ "is_apex_domain": true,
667
+ "should_be_a_record": true,
668
+ "is_cname_to_github_user_domain": false,
669
+ "is_cname_to_pages_dot_github_dot_com": false,
670
+ "is_cname_to_fastly": false,
671
+ "is_pointed_to_github_pages_ip": true,
672
+ "is_non_github_pages_ip_present": false,
673
+ "is_pages_domain": false,
674
+ "is_served_by_pages": true,
675
+ "is_valid": true,
676
+ "reason": "some reason",
677
+ "responds_to_https": true,
678
+ "enforces_https": true,
679
+ "https_error": "some error",
680
+ "is_https_eligible": true,
681
+ "caa_error": "some error"
682
+ },
683
+ "alt_domain": {
684
+ "host": "www.example.com",
685
+ "uri": "http://www.example.com/",
686
+ "nameservers": "default",
687
+ "dns_resolves": true
688
+ }
689
+ }`
690
+
691
+ testJSONMarshal (t , u , want )
692
+ }
693
+
562
694
func TestCreatePagesRequest_Marshal (t * testing.T ) {
563
695
testJSONMarshal (t , & createPagesRequest {}, "{}" )
564
696
0 commit comments