(t *testing.T)
| 2385 | } |
| 2386 | |
| 2387 | func TestGenericInsights_Disabled(t *testing.T) { |
| 2388 | t.Parallel() |
| 2389 | |
| 2390 | db, ps := dbtestutil.NewDB(t) |
| 2391 | logger := testutil.Logger(t) |
| 2392 | client := coderdtest.New(t, &coderdtest.Options{ |
| 2393 | Database: db, |
| 2394 | Pubsub: ps, |
| 2395 | Logger: &logger, |
| 2396 | IncludeProvisionerDaemon: true, |
| 2397 | AgentStatsRefreshInterval: time.Millisecond * 100, |
| 2398 | DatabaseRolluper: dbrollup.New( |
| 2399 | logger.Named("dbrollup"), |
| 2400 | db, |
| 2401 | dbrollup.WithInterval(time.Millisecond*100), |
| 2402 | ), |
| 2403 | DeploymentValues: coderdtest.DeploymentValues(t, func(dv *codersdk.DeploymentValues) { |
| 2404 | dv.StatsCollection = codersdk.StatsCollectionConfig{ |
| 2405 | UsageStats: codersdk.UsageStatsConfig{ |
| 2406 | Enable: false, |
| 2407 | }, |
| 2408 | } |
| 2409 | }), |
| 2410 | }) |
| 2411 | user := coderdtest.CreateFirstUser(t, client) |
| 2412 | _, _ = coderdtest.CreateAnotherUser(t, client, user.OrganizationID) |
| 2413 | |
| 2414 | tests := []struct { |
| 2415 | name string |
| 2416 | fn func(ctx context.Context) error |
| 2417 | // ok means there should be no error, otherwise assume 404 due to being |
| 2418 | // disabled. |
| 2419 | ok bool |
| 2420 | }{ |
| 2421 | { |
| 2422 | name: "DAUS", |
| 2423 | fn: func(ctx context.Context) error { |
| 2424 | _, err := client.DeploymentDAUs(ctx, 0) |
| 2425 | return err |
| 2426 | }, |
| 2427 | }, |
| 2428 | { |
| 2429 | name: "UserActivity", |
| 2430 | fn: func(ctx context.Context) error { |
| 2431 | _, err := client.UserActivityInsights(ctx, codersdk.UserActivityInsightsRequest{}) |
| 2432 | return err |
| 2433 | }, |
| 2434 | }, |
| 2435 | { |
| 2436 | name: "UserLatency", |
| 2437 | fn: func(ctx context.Context) error { |
| 2438 | _, err := client.UserLatencyInsights(ctx, codersdk.UserLatencyInsightsRequest{}) |
| 2439 | return err |
| 2440 | }, |
| 2441 | }, |
| 2442 | { |
| 2443 | name: "UserStatusCounts", |
| 2444 | fn: func(ctx context.Context) error { |
nothing calls this directly
no test coverage detected