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

Function Test_apiRun_invokingAgent

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

Source from the content-addressed store, hash-verified

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