(t *testing.T)
| 1570 | } |
| 1571 | |
| 1572 | func 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 | |
| 1602 | func Test_openUserFile(t *testing.T) { |
| 1603 | f, err := os.CreateTemp(t.TempDir(), "gh-test") |
nothing calls this directly
no test coverage detected