MCPcopy
hub / github.com/cli/cli / Test_apiRun_invokingAgent

Function Test_apiRun_invokingAgent

pkg/cmd/api/api_test.go:1391–1419  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1389}
1390
1391func Test_apiRun_invokingAgent(t *testing.T) {
1392 var receivedUA string
1393 s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1394 receivedUA = r.Header.Get("User-Agent")
1395 w.WriteHeader(http.StatusNoContent)
1396 }))
1397 t.Cleanup(s.Close)
1398
1399 ios, _, _, _ := iostreams.Test()
1400 options := ApiOptions{
1401 IO: ios,
1402 AppVersion: "1.2.3",
1403 InvokingAgent: "copilot-cli",
1404 Config: func() (gh.Config, error) {
1405 return &ghmock.ConfigMock{
1406 AuthenticationFunc: func() gh.AuthConfig {
1407 cfg := &config.AuthConfig{}
1408 cfg.SetActiveToken("token", "stub")
1409 return cfg
1410 },
1411 }, nil
1412 },
1413 RequestPath: s.URL,
1414 }
1415
1416 require.NoError(t, apiRun(&options))
1417 assert.Contains(t, receivedUA, "GitHub CLI 1.2.3")
1418 assert.Contains(t, receivedUA, "Agent/copilot-cli")
1419}
1420
1421func Test_openUserFile(t *testing.T) {
1422 f, err := os.CreateTemp(t.TempDir(), "gh-test")

Callers

nothing calls this directly

Calls 5

SetActiveTokenMethod · 0.95
TestFunction · 0.92
apiRunFunction · 0.85
ContainsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected