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

Function TestRefreshTelemetryReportsCommand

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

Source from the content-addressed store, hash-verified

198}
199
200func TestRefreshTelemetryReportsCommand(t *testing.T) {
201 tests := []struct {
202 name string
203 command string
204 want string
205 }{
206 {name: "set", command: "gh auth token", want: "gh auth token"},
207 {name: "not set yet", want: "unknown"},
208 }
209 for _, tt := range tests {
210 t.Run(tt.name, func(t *testing.T) {
211 authCfg := newTestAuthConfig(t)
212 loginRefreshableWithExpiry(t, authCfg, "github.com", "test-user", "old-access", "old-refresh", time.Now().Add(-time.Hour), false)
213 authCfg.SetTokenRefresher(renewingRefresher())
214 if tt.command != "" {
215 authCfg.SetTelemetryCommand(tt.command)
216 }
217 spy := &refreshTelemetrySpy{}
218 authCfg.SetTelemetryRecorder(spy)
219
220 _, _, err := authCfg.ActiveTokenWithRefresh("github.com")
221
222 require.NoError(t, err)
223 require.Len(t, spy.events, 1)
224 require.Equal(t, tt.want, spy.events[0].Dimensions["refresh_command"])
225 })
226 }
227}
228
229func TestRefreshTelemetryRecordsUnfinishedAttempts(t *testing.T) {
230 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