(t *testing.T)
| 3409 | } |
| 3410 | |
| 3411 | func TestCopilotService_DownloadUserPeriodicMetrics(t *testing.T) { |
| 3412 | t.Parallel() |
| 3413 | client, mux, _ := setup(t) |
| 3414 | |
| 3415 | mux.HandleFunc("/path/to/users-periodic", func(w http.ResponseWriter, r *http.Request) { |
| 3416 | testMethod(t, r, "GET") |
| 3417 | fmt.Fprint(w, `{"report_start_day":"2026-03-05","report_end_day":"2026-04-01","day":"2026-03-05","user_id":1,"user_login":"alice","user_initiated_interaction_count":3,"used_copilot_code_review_active":true} |
| 3418 | {"report_start_day":"2026-03-05","report_end_day":"2026-04-01","day":"2026-03-06","user_id":1,"user_login":"alice","used_cli":true,"used_copilot_code_review_passive":true,"used_copilot_coding_agent":true,"totals_by_cli":{"session_count":1,"request_count":3,"prompt_count":2,"token_usage":{"avg_tokens_per_request":1200.5,"output_tokens_sum":2400,"prompt_tokens_sum":1201}}} |
| 3419 | `) |
| 3420 | }) |
| 3421 | |
| 3422 | ctx := t.Context() |
| 3423 | url := client.baseURL.String() + "path/to/users-periodic" |
| 3424 | got, resp, err := client.Copilot.DownloadUserPeriodicMetrics(ctx, url) |
| 3425 | if err != nil { |
| 3426 | t.Errorf("Copilot.DownloadUserPeriodicMetrics returned error: %v", err) |
| 3427 | } |
| 3428 | if resp.StatusCode != http.StatusOK { |
| 3429 | t.Errorf("Copilot.DownloadUserPeriodicMetrics returned status code: %v", resp.StatusCode) |
| 3430 | } |
| 3431 | |
| 3432 | want := []*CopilotUserPeriodicMetrics{ |
| 3433 | { |
| 3434 | ReportStartDay: "2026-03-05", |
| 3435 | ReportEndDay: "2026-04-01", |
| 3436 | Day: "2026-03-05", |
| 3437 | UserID: 1, |
| 3438 | UserLogin: "alice", |
| 3439 | UserInitiatedInteractionCount: Ptr(3), |
| 3440 | UsedCopilotCodeReviewActive: Ptr(true), |
| 3441 | }, |
| 3442 | { |
| 3443 | ReportStartDay: "2026-03-05", |
| 3444 | ReportEndDay: "2026-04-01", |
| 3445 | Day: "2026-03-06", |
| 3446 | UserID: 1, |
| 3447 | UserLogin: "alice", |
| 3448 | UsedCLI: Ptr(true), |
| 3449 | UsedCopilotCodeReviewPassive: Ptr(true), |
| 3450 | UsedCopilotCodingAgent: Ptr(true), |
| 3451 | TotalsByCLI: &CopilotMetricsCLI{ |
| 3452 | SessionCount: Ptr(1), |
| 3453 | RequestCount: Ptr(3), |
| 3454 | PromptCount: Ptr(2), |
| 3455 | TokenUsage: &CopilotMetricsCLITokenUsage{ |
| 3456 | AvgTokensPerRequest: Ptr(1200.5), |
| 3457 | OutputTokensSum: Ptr(2400), |
| 3458 | PromptTokensSum: Ptr(1201), |
| 3459 | }, |
| 3460 | }, |
| 3461 | }, |
| 3462 | } |
| 3463 | |
| 3464 | if !cmp.Equal(got, want) { |
| 3465 | t.Errorf("Copilot.DownloadUserPeriodicMetrics returned %+v, want %+v", got, want) |
| 3466 | } |
| 3467 | |
| 3468 | // Empty body parses to a nil slice (no records). |
nothing calls this directly
no test coverage detected
searching dependent graphs…