| 490 | } |
| 491 | |
| 492 | func TestCheckHost(t *testing.T) { |
| 493 | tests := []struct { |
| 494 | name string |
| 495 | host string |
| 496 | wantErr string |
| 497 | }{ |
| 498 | {name: "github.com", host: "github.com"}, |
| 499 | {name: "data residency tenant", host: "acme.ghe.com"}, |
| 500 | {name: "localhost", host: "github.localhost"}, |
| 501 | { |
| 502 | name: "enterprise server", |
| 503 | host: "github.example.com", |
| 504 | wantErr: "attaching files is not supported on GitHub Enterprise Server", |
| 505 | }, |
| 506 | } |
| 507 | |
| 508 | for _, tt := range tests { |
| 509 | t.Run(tt.name, func(t *testing.T) { |
| 510 | err := checkHost(tt.host) |
| 511 | |
| 512 | if tt.wantErr == "" { |
| 513 | require.NoError(t, err) |
| 514 | return |
| 515 | } |
| 516 | require.EqualError(t, err, tt.wantErr) |
| 517 | }) |
| 518 | } |
| 519 | } |