diff --git a/pkg/cli/audit_report_experiments_test.go b/pkg/cli/audit_report_experiments_test.go index a82513bb931..49d6fddb8ad 100644 --- a/pkg/cli/audit_report_experiments_test.go +++ b/pkg/cli/audit_report_experiments_test.go @@ -15,10 +15,12 @@ import ( func TestFindExperimentStatePath(t *testing.T) { t.Parallel() t.Run("returns empty when logsPath is empty", func(t *testing.T) { + t.Parallel() assert.Empty(t, findExperimentStatePath(""), "should return empty string for empty logsPath") }) t.Run("finds state.json at root", func(t *testing.T) { + t.Parallel() dir := t.TempDir() statePath := filepath.Join(dir, "state.json") require.NoError(t, os.WriteFile(statePath, []byte("{}"), 0o600)) @@ -28,6 +30,7 @@ func TestFindExperimentStatePath(t *testing.T) { }) t.Run("prefers state.jsonl at root", func(t *testing.T) { + t.Parallel() dir := t.TempDir() require.NoError(t, os.WriteFile(filepath.Join(dir, "state.json"), []byte("{}"), 0o600)) statePath := filepath.Join(dir, "state.jsonl") @@ -38,6 +41,7 @@ func TestFindExperimentStatePath(t *testing.T) { }) t.Run("finds state.json in experiment subdirectory", func(t *testing.T) { + t.Parallel() dir := t.TempDir() subDir := filepath.Join(dir, "experiment") require.NoError(t, os.MkdirAll(subDir, 0o755)) @@ -49,6 +53,7 @@ func TestFindExperimentStatePath(t *testing.T) { }) t.Run("returns empty when no state.json exists", func(t *testing.T) { + t.Parallel() dir := t.TempDir() got := findExperimentStatePath(dir) assert.Empty(t, got, "should return empty string when no state.json found") @@ -58,27 +63,32 @@ func TestFindExperimentStatePath(t *testing.T) { func TestExtractExperimentData(t *testing.T) { t.Parallel() t.Run("returns nil for empty logsPath", func(t *testing.T) { + t.Parallel() assert.Nil(t, extractExperimentData(""), "should return nil for empty logsPath") }) t.Run("returns nil when no state.json present", func(t *testing.T) { + t.Parallel() dir := t.TempDir() assert.Nil(t, extractExperimentData(dir), "should return nil when state.json missing") }) t.Run("returns nil for invalid JSON", func(t *testing.T) { + t.Parallel() dir := t.TempDir() require.NoError(t, os.WriteFile(filepath.Join(dir, "state.json"), []byte("not-json"), 0o600)) assert.Nil(t, extractExperimentData(dir), "should return nil for invalid JSON") }) t.Run("returns nil for empty counts", func(t *testing.T) { + t.Parallel() dir := t.TempDir() require.NoError(t, os.WriteFile(filepath.Join(dir, "state.json"), []byte(`{"counts":{}}`), 0o600)) assert.Nil(t, extractExperimentData(dir), "should return nil when counts map is empty") }) t.Run("extracts single experiment with two variants", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -97,6 +107,7 @@ func TestExtractExperimentData(t *testing.T) { }) t.Run("reads state.json from experiment subdirectory", func(t *testing.T) { + t.Parallel() dir := t.TempDir() subDir := filepath.Join(dir, "experiment") require.NoError(t, os.MkdirAll(subDir, 0o755)) @@ -115,6 +126,7 @@ func TestExtractExperimentData(t *testing.T) { }) t.Run("reads state.jsonl run ledger", func(t *testing.T) { + t.Parallel() dir := t.TempDir() raw := []byte(`{"run_id":"0","timestamp":"2026-07-31T23:00:00Z","assignments":{"style":"concise"}} {"run_id":"1","timestamp":"2026-08-01T00:00:00Z","assignments":{"style":"concise"}} @@ -129,6 +141,7 @@ func TestExtractExperimentData(t *testing.T) { }) t.Run("extracts multiple experiments", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -184,6 +197,7 @@ func TestFormatExperimentLabel(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := formatExperimentLabel(tt.exp) assert.Equal(t, tt.expected, got, "formatExperimentLabel result mismatch") }) @@ -266,6 +280,7 @@ func TestExperimentMatchesFilter(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := experimentMatchesFilter(tt.exp, tt.experimentName, tt.variant) assert.Equal(t, tt.want, got, "experimentMatchesFilter result mismatch") }) @@ -306,6 +321,7 @@ func TestFormatExperimentSkipMessage(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := formatExperimentSkipMessage(tt.runID, tt.experiment, tt.variant) assert.Contains(t, got, tt.wantSubstr, "formatExperimentSkipMessage output mismatch") }) @@ -348,6 +364,7 @@ func TestDeriveLastSelectedVariant(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := deriveLastSelectedVariant(tt.counts) assert.Equal(t, tt.expected, got, "deriveLastSelectedVariant result mismatch") }) @@ -357,6 +374,7 @@ func TestDeriveLastSelectedVariant(t *testing.T) { func TestFirstExperimentAssignment(t *testing.T) { t.Parallel() t.Run("returns false for nil", func(t *testing.T) { + t.Parallel() name, variant, ok := firstExperimentAssignment(nil) assert.False(t, ok) assert.Empty(t, name) @@ -364,6 +382,7 @@ func TestFirstExperimentAssignment(t *testing.T) { }) t.Run("returns false for empty assignments", func(t *testing.T) { + t.Parallel() name, variant, ok := firstExperimentAssignment(&ExperimentData{Assignments: map[string]string{}}) assert.False(t, ok) assert.Empty(t, name) @@ -371,6 +390,7 @@ func TestFirstExperimentAssignment(t *testing.T) { }) t.Run("returns alphabetically first assignment", func(t *testing.T) { + t.Parallel() exp := &ExperimentData{ Assignments: map[string]string{ "style": "concise", @@ -387,6 +407,7 @@ func TestFirstExperimentAssignment(t *testing.T) { func TestExtractExperimentDataWithRuns(t *testing.T) { t.Parallel() t.Run("uses last run record when runs array is present", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -417,6 +438,7 @@ func TestExtractExperimentDataWithRuns(t *testing.T) { }) t.Run("falls back to heuristic when runs array is empty", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -435,6 +457,7 @@ func TestExtractExperimentDataWithRuns(t *testing.T) { }) t.Run("falls back to heuristic when runs field is absent (legacy state)", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -451,6 +474,7 @@ func TestExtractExperimentDataWithRuns(t *testing.T) { }) t.Run("skips last run record with empty assignments", func(t *testing.T) { + t.Parallel() dir := t.TempDir() state := map[string]any{ "counts": map[string]any{ @@ -478,6 +502,7 @@ func TestExtractExperimentDataWithRuns(t *testing.T) { func TestExtractExperimentDataFallsBackToUsageSummary(t *testing.T) { t.Parallel() t.Run("reads assignments from usage activity summary when no state file present", func(t *testing.T) { + t.Parallel() dir := t.TempDir() usageDir := filepath.Join(dir, "usage", "activity") require.NoError(t, os.MkdirAll(usageDir, 0o755)) @@ -500,6 +525,7 @@ func TestExtractExperimentDataFallsBackToUsageSummary(t *testing.T) { }) t.Run("prefers state file over usage summary when both exist", func(t *testing.T) { + t.Parallel() dir := t.TempDir() // Write experiment state file @@ -532,6 +558,7 @@ func TestExtractExperimentDataFallsBackToUsageSummary(t *testing.T) { }) t.Run("returns nil when usage summary has no experiments field", func(t *testing.T) { + t.Parallel() dir := t.TempDir() usageDir := filepath.Join(dir, "usage", "activity") require.NoError(t, os.MkdirAll(usageDir, 0o755)) diff --git a/pkg/cli/audit_report_helpers_test.go b/pkg/cli/audit_report_helpers_test.go index d752a85a39e..c1a5208210e 100644 --- a/pkg/cli/audit_report_helpers_test.go +++ b/pkg/cli/audit_report_helpers_test.go @@ -61,6 +61,7 @@ func TestParseDurationString(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := parseDurationString(tt.input) if got != tt.expected { t.Errorf("parseDurationString(%q) = %v, want %v", tt.input, got, tt.expected) @@ -129,6 +130,7 @@ func TestTruncateString(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() got := stringutil.Truncate(tt.input, tt.maxLen) if got != tt.expected { t.Errorf("stringutil.Truncate(%q, %d) = %q, want %q", tt.input, tt.maxLen, got, tt.expected) @@ -357,6 +359,7 @@ func TestAuditReportFileListingIntegration(t *testing.T) { for _, tc := range testCases { t.Run(tc.path, func(t *testing.T) { + t.Parallel() info, ok := fileMap[tc.path] if !ok { t.Fatalf("File %s not found in extracted files", tc.path) diff --git a/pkg/cli/awinfo_steps_test.go b/pkg/cli/awinfo_steps_test.go index 9638207c2a8..6ebfef189ad 100644 --- a/pkg/cli/awinfo_steps_test.go +++ b/pkg/cli/awinfo_steps_test.go @@ -72,6 +72,7 @@ func TestAwInfoStepsFieldParsing(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() var info AwInfo err := json.Unmarshal([]byte(tt.jsonContent), &info) require.NoError(t, err, "Failed to unmarshal JSON") @@ -137,6 +138,7 @@ func TestGetFirewallVersion(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() assert.Equal(t, tt.expected, tt.info.GetFirewallVersion(), tt.name) }) }