MCPcopy Index your code
hub / github.com/cli/cli / TestIsHostSupported

Function TestIsHostSupported

pkg/cmd/attestation/auth/host_test.go:11–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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}

Callers

nothing calls this directly

Calls 3

IsHostSupportedFunction · 0.85
RunMethod · 0.65
DefaultHostMethod · 0.65

Tested by

no test coverage detected