MCPcopy Index your code
hub / github.com/coder/coder / collectSnapshot

Function collectSnapshot

coderd/telemetry/telemetry_test.go:1407–1432  ·  view source on GitHub ↗
(
	ctx context.Context,
	t *testing.T,
	db database.Store,
	addOptionsFn func(opts telemetry.Options) telemetry.Options,
)

Source from the content-addressed store, hash-verified

1405}
1406
1407func collectSnapshot(
1408 ctx context.Context,
1409 t *testing.T,
1410 db database.Store,
1411 addOptionsFn func(opts telemetry.Options) telemetry.Options,
1412) (*telemetry.Deployment, *telemetry.Snapshot) {
1413 t.Helper()
1414
1415 serverURL, deployment, snapshot := mockTelemetryServer(ctx, t)
1416
1417 options := telemetry.Options{
1418 Database: db,
1419 Logger: testutil.Logger(t),
1420 URL: serverURL,
1421 DeploymentID: uuid.NewString(),
1422 }
1423 if addOptionsFn != nil {
1424 options = addOptionsFn(options)
1425 }
1426
1427 reporter, err := telemetry.New(options)
1428 require.NoError(t, err)
1429 t.Cleanup(reporter.Close)
1430
1431 return testutil.RequireReceive(ctx, t, deployment), testutil.RequireReceive(ctx, t, snapshot)
1432}
1433
1434func TestTelemetry_BoundaryUsageSummary(t *testing.T) {
1435 t.Parallel()

Callers 7

TestTelemetryFunction · 0.85
TestChatsTelemetryFunction · 0.85
TestUserSecretsTelemetryFunction · 0.85

Calls 6

LoggerFunction · 0.92
NewFunction · 0.92
RequireReceiveFunction · 0.92
mockTelemetryServerFunction · 0.70
HelperMethod · 0.65
CleanupMethod · 0.65

Tested by

no test coverage detected