(t *testing.T)
| 198 | } |
| 199 | |
| 200 | func 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 | |
| 229 | func TestRefreshTelemetryRecordsUnfinishedAttempts(t *testing.T) { |
| 230 | t.Run("when reloading the configuration fails", func(t *testing.T) { |
nothing calls this directly
no test coverage detected