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