(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestIsHostSupported(t *testing.T) { |
| 12 | testcases := []struct { |
| 13 | name string |
| 14 | expectedErr bool |
| 15 | host string |
| 16 | }{ |
| 17 | { |
| 18 | name: "Default github.com host", |
| 19 | expectedErr: false, |
| 20 | host: "github.com", |
| 21 | }, |
| 22 | { |
| 23 | name: "Localhost", |
| 24 | expectedErr: false, |
| 25 | host: "github.localhost", |
| 26 | }, |
| 27 | { |
| 28 | name: "No host set", |
| 29 | expectedErr: false, |
| 30 | host: "", |
| 31 | }, |
| 32 | { |
| 33 | name: "GHE tenant host", |
| 34 | expectedErr: false, |
| 35 | host: "some-tenant.ghe.com", |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range testcases { |
| 40 | t.Run(tc.name, func(t *testing.T) { |
| 41 | t.Setenv("GH_HOST", tc.host) |
| 42 | |
| 43 | host, _ := ghauth.DefaultHost() |
| 44 | err := IsHostSupported(host) |
| 45 | if tc.expectedErr { |
| 46 | require.ErrorIs(t, err, ErrUnsupportedHost) |
| 47 | } else { |
| 48 | require.NoError(t, err) |
| 49 | } |
| 50 | }) |
| 51 | } |
| 52 | } |
nothing calls this directly
no test coverage detected