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

Function TestRefreshTelemetryReportsCommand

internal/config/refreshable_telemetry_test.go:389–416  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

387}
388
389func 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
418func TestRefreshTelemetryRecordsUnfinishedAttempts(t *testing.T) {
419 t.Run("when reloading the configuration fails", func(t *testing.T) {

Callers

nothing calls this directly

Calls 11

newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
renewingRefresherFunction · 0.70
RunMethod · 0.65
AddMethod · 0.65
SetTokenRefresherMethod · 0.65
SetTelemetryCommandMethod · 0.65
SetTelemetryRecorderMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected