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

Function Test_apiRun_invokingAgent

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

Source from the content-addressed store, hash-verified

1570}
1571
1572func Test_apiRun_invokingAgent(t *testing.T) {
1573 var receivedUA string
1574 s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1575 receivedUA = r.Header.Get("User-Agent")
1576 w.WriteHeader(http.StatusNoContent)
1577 }))
1578 t.Cleanup(s.Close)
1579
1580 ios, _, _, _ := iostreams.Test()
1581 options := ApiOptions{
1582 IO: ios,
1583 AppVersion: "1.2.3",
1584 InvokingAgent: "copilot-cli",
1585 Config: func() (gh.Config, error) {
1586 return &ghmock.ConfigMock{
1587 AuthenticationFunc: func() gh.AuthConfig {
1588 cfg := &config.AuthConfig{}
1589 cfg.SetActiveToken("token", "stub")
1590 return cfg
1591 },
1592 }, nil
1593 },
1594 RequestPath: s.URL,
1595 }
1596
1597 require.NoError(t, apiRun(&options))
1598 assert.Contains(t, receivedUA, "GitHub CLI 1.2.3")
1599 assert.Contains(t, receivedUA, "Agent/copilot-cli")
1600}
1601
1602func Test_openUserFile(t *testing.T) {
1603 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