| 552 | } |
| 553 | |
| 554 | func TestCheckHost(t *testing.T) { |
| 555 | tests := []struct { |
| 556 | name string |
| 557 | host string |
| 558 | wantErr string |
| 559 | }{ |
| 560 | {name: "github.com", host: "github.com"}, |
| 561 | {name: "data residency tenant", host: "acme.ghe.com"}, |
| 562 | {name: "localhost", host: "github.localhost"}, |
| 563 | { |
| 564 | name: "enterprise server", |
| 565 | host: "github.example.com", |
| 566 | wantErr: "attaching files is not supported on GitHub Enterprise Server", |
| 567 | }, |
| 568 | } |
| 569 | |
| 570 | for _, tt := range tests { |
| 571 | t.Run(tt.name, func(t *testing.T) { |
| 572 | err := checkHost(tt.host) |
| 573 | |
| 574 | if tt.wantErr == "" { |
| 575 | require.NoError(t, err) |
| 576 | return |
| 577 | } |
| 578 | require.EqualError(t, err, tt.wantErr) |
| 579 | }) |
| 580 | } |
| 581 | } |