(t *testing.T)
| 3198 | } |
| 3199 | |
| 3200 | func TestCopilotService_DownloadPeriodicMetrics(t *testing.T) { |
| 3201 | t.Parallel() |
| 3202 | client, mux, _ := setup(t) |
| 3203 | |
| 3204 | mux.HandleFunc("/path/to/periodic", func(w http.ResponseWriter, r *http.Request) { |
| 3205 | testMethod(t, r, "GET") |
| 3206 | fmt.Fprint(w, `{ |
| 3207 | "report_start_day": "2026-03-05", |
| 3208 | "report_end_day": "2026-04-01", |
| 3209 | "organization_id": "123", |
| 3210 | "created_at": "2026-04-02T00:00:00Z", |
| 3211 | "day_totals": [ |
| 3212 | { |
| 3213 | "day": "2026-03-05", |
| 3214 | "daily_active_cli_users": 2, |
| 3215 | "daily_active_users": 5, |
| 3216 | "totals_by_cli": { |
| 3217 | "session_count": 1, |
| 3218 | "request_count": 2, |
| 3219 | "prompt_count": 1, |
| 3220 | "token_usage": { |
| 3221 | "avg_tokens_per_request": 4000.0, |
| 3222 | "output_tokens_sum": 5000, |
| 3223 | "prompt_tokens_sum": 3000 |
| 3224 | } |
| 3225 | }, |
| 3226 | "pull_requests": { |
| 3227 | "median_minutes_to_merge": 8.5, |
| 3228 | "median_minutes_to_merge_copilot_authored": 5.0, |
| 3229 | "median_minutes_to_merge_copilot_reviewed": 7.0 |
| 3230 | } |
| 3231 | }, |
| 3232 | {"day": "2026-03-06", "daily_active_users": 7} |
| 3233 | ] |
| 3234 | }`) |
| 3235 | }) |
| 3236 | |
| 3237 | ctx := t.Context() |
| 3238 | url := client.baseURL.String() + "path/to/periodic" |
| 3239 | got, resp, err := client.Copilot.DownloadPeriodicMetrics(ctx, url) |
| 3240 | if err != nil { |
| 3241 | t.Errorf("Copilot.DownloadPeriodicMetrics returned error: %v", err) |
| 3242 | } |
| 3243 | if resp.StatusCode != http.StatusOK { |
| 3244 | t.Errorf("Copilot.DownloadPeriodicMetrics returned status code: %v", resp.StatusCode) |
| 3245 | } |
| 3246 | |
| 3247 | want := &CopilotPeriodicMetrics{ |
| 3248 | ReportStartDay: "2026-03-05", |
| 3249 | ReportEndDay: "2026-04-01", |
| 3250 | OrganizationID: Ptr("123"), |
| 3251 | CreatedAt: &Timestamp{time.Date(2026, 4, 2, 0, 0, 0, 0, time.UTC)}, |
| 3252 | DayTotals: []*CopilotDailyMetrics{ |
| 3253 | { |
| 3254 | Day: "2026-03-05", |
| 3255 | DailyActiveCLIUsers: Ptr(2), |
| 3256 | DailyActiveUsers: Ptr(5), |
| 3257 | TotalsByCLI: &CopilotMetricsCLI{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…