MCPcopy
hub / github.com/cli/cli / TestCapiClientFuncResolvesURL

Function TestCapiClientFuncResolvesURL

pkg/cmd/agent-task/shared/capi_test.go:64–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func 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
98func TestIsSession(t *testing.T) {
99 assert.True(t, IsSessionID("00000000-0000-0000-0000-000000000000"))

Callers

nothing calls this directly

Calls 8

VerifyMethod · 0.95
RegisterMethod · 0.95
SetDefaultHostMethod · 0.95
SetActiveTokenMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
CapiClientFuncFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected