(t *testing.T)
| 1389 | } |
| 1390 | |
| 1391 | func 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 | |
| 1421 | func Test_openUserFile(t *testing.T) { |
| 1422 | f, err := os.CreateTemp(t.TempDir(), "gh-test") |
nothing calls this directly
no test coverage detected