(t *testing.T)
| 387 | } |
| 388 | |
| 389 | func TestRefreshTelemetryReportsCommand(t *testing.T) { |
| 390 | tests := []struct { |
| 391 | name string |
| 392 | command string |
| 393 | want string |
| 394 | }{ |
| 395 | {name: "set", command: "gh auth token", want: "gh auth token"}, |
| 396 | {name: "not set yet", want: "unknown"}, |
| 397 | } |
| 398 | for _, tt := range tests { |
| 399 | t.Run(tt.name, func(t *testing.T) { |
| 400 | authCfg := newTestAuthConfig(t) |
| 401 | loginRefreshableWithExpiry(t, authCfg, "github.com", "test-user", "old-access", "old-refresh", time.Now().Add(-time.Hour), false) |
| 402 | authCfg.SetTokenRefresher(renewingRefresher()) |
| 403 | if tt.command != "" { |
| 404 | authCfg.SetTelemetryCommand(tt.command) |
| 405 | } |
| 406 | spy := &refreshTelemetrySpy{} |
| 407 | authCfg.SetTelemetryRecorder(spy) |
| 408 | |
| 409 | _, _, err := authCfg.ActiveTokenWithRefresh("github.com") |
| 410 | |
| 411 | require.NoError(t, err) |
| 412 | require.Len(t, spy.events, 1) |
| 413 | require.Equal(t, tt.want, spy.events[0].Dimensions["refresh_command"]) |
| 414 | }) |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | func TestRefreshTelemetryRecordsUnfinishedAttempts(t *testing.T) { |
| 419 | t.Run("when reloading the configuration fails", func(t *testing.T) { |
nothing calls this directly
no test coverage detected