MCPcopy Create free account
hub / github.com/cli/cli / Test_apiRun_invokingAgent

Function Test_apiRun_invokingAgent

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

Source from the content-addressed store, hash-verified

1469}
1470
1471func Test_apiRun_invokingAgent(t *testing.T) {
1472 var receivedUA string
1473 s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1474 receivedUA = r.Header.Get("User-Agent")
1475 w.WriteHeader(http.StatusNoContent)
1476 }))
1477 t.Cleanup(s.Close)
1478
1479 ios, _, _, _ := iostreams.Test()
1480 options := ApiOptions{
1481 IO: ios,
1482 AppVersion: "1.2.3",
1483 InvokingAgent: "copilot-cli",
1484 Config: func() (gh.Config, error) {
1485 return &ghmock.ConfigMock{
1486 AuthenticationFunc: func() gh.AuthConfig {
1487 cfg := &config.AuthConfig{}
1488 cfg.SetActiveToken("token", "stub")
1489 return cfg
1490 },
1491 }, nil
1492 },
1493 RequestPath: s.URL,
1494 }
1495
1496 require.NoError(t, apiRun(&options))
1497 assert.Contains(t, receivedUA, "GitHub CLI 1.2.3")
1498 assert.Contains(t, receivedUA, "Agent/copilot-cli")
1499}
1500
1501func Test_openUserFile(t *testing.T) {
1502 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