(t *testing.T)
| 62 | } |
| 63 | |
| 64 | func TestCapiClientFuncResolvesURL(t *testing.T) { |
| 65 | reg := &httpmock.Registry{} |
| 66 | defer reg.Verify(t) |
| 67 | |
| 68 | reg.Register( |
| 69 | httpmock.GraphQL(`query CopilotEndpoints\b`), |
| 70 | httpmock.StringResponse(`{"data":{"viewer":{"copilotEndpoints":{"api":"https://test-copilot-api.example.com"}}}}`), |
| 71 | ) |
| 72 | |
| 73 | f := &cmdutil.Factory{ |
| 74 | Config: func() (gh.Config, error) { |
| 75 | return &ghmock.ConfigMock{ |
| 76 | AuthenticationFunc: func() gh.AuthConfig { |
| 77 | c := &config.AuthConfig{} |
| 78 | c.SetDefaultHost("github.com", "hosts") |
| 79 | c.SetActiveToken("gho_TOKEN", "oauth_token") |
| 80 | return c |
| 81 | }, |
| 82 | }, nil |
| 83 | }, |
| 84 | HttpClient: func() (*http.Client, error) { |
| 85 | return &http.Client{Transport: reg}, nil |
| 86 | }, |
| 87 | } |
| 88 | |
| 89 | clientFunc := CapiClientFunc(f) |
| 90 | client, err := clientFunc() |
| 91 | require.NoError(t, err) |
| 92 | require.NotNil(t, client) |
| 93 | |
| 94 | // Verify the GraphQL resolution was called |
| 95 | require.Len(t, reg.Requests, 1) |
| 96 | } |
| 97 | |
| 98 | func TestIsSession(t *testing.T) { |
| 99 | assert.True(t, IsSessionID("00000000-0000-0000-0000-000000000000")) |
nothing calls this directly
no test coverage detected