(t *testing.T)
| 1469 | } |
| 1470 | |
| 1471 | func 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 | |
| 1501 | func Test_openUserFile(t *testing.T) { |
| 1502 | f, err := os.CreateTemp(t.TempDir(), "gh-test") |
nothing calls this directly
no test coverage detected