From 16cc4b3f63ffe4c9965c29cc4c982315449ab1cf Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sat, 20 Jun 2026 13:33:30 +0000 Subject: [PATCH] Update app workflow path expectations --- internal/app/app_test.go | 10 ++--- internal/cli/root_test.go | 92 ++++++++++++++++++++++----------------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/internal/app/app_test.go b/internal/app/app_test.go index 2bcff92..6781ec1 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -255,7 +255,7 @@ func TestGenerateReportWritesReportAndPreflight(t *testing.T) { if err != nil { t.Fatalf("read data package: %v", err) } - if !strings.HasSuffix(result.DataPackagePath, ".data_package.yaml") { + if !strings.HasPrefix(filepath.Base(result.DataPackagePath), "data_package.") || !strings.HasSuffix(result.DataPackagePath, ".yaml") { t.Fatalf("DataPackagePath = %q, want YAML data package path", result.DataPackagePath) } if !strings.Contains(string(data), "schema_version: weatherreporter.data_package.v3") || @@ -2548,12 +2548,12 @@ func TestBatchResultJSONIncludesNotification(t *testing.T) { PipelineID: "weatherreporter", BundleID: "weatherreporter.home.evening", IdempotencyKey: "weatherreporter.home.evening.20260529T233000.000000000Z_evening", - Path: "notifications/batches/evening/2026-05-29/20260529T233000.000000000Z_evening.distributor.json", + Path: "notifications/batches/evening/2026-05-29/distributor.20260529T233000.000000000Z_evening.json", IncludedReports: []BatchNotificationReport{ { ReportID: report.Tomorrow, RunID: "20260529T233000.000000000Z_tomorrow", - SourcePath: "reports/tomorrow.md", + SourcePath: "reports/tomorrow/2026-05-30/report.20260529T233000.000000000Z_tomorrow.md", BundlePaths: []string{"tomorrow/index.md"}, }, }, @@ -2573,10 +2573,10 @@ func TestBatchResultJSONIncludesNotification(t *testing.T) { `"pipelineId":"weatherreporter"`, `"bundleId":"weatherreporter.home.evening"`, `"idempotencyKey":"weatherreporter.home.evening.20260529T233000.000000000Z_evening"`, - `"path":"notifications/batches/evening/2026-05-29/20260529T233000.000000000Z_evening.distributor.json"`, + `"path":"notifications/batches/evening/2026-05-29/distributor.20260529T233000.000000000Z_evening.json"`, `"includedReports":[`, `"reportId":"tomorrow"`, - `"sourcePath":"reports/tomorrow.md"`, + `"sourcePath":"reports/tomorrow/2026-05-30/report.20260529T233000.000000000Z_tomorrow.md"`, `"bundlePaths":["tomorrow/index.md"]`, } { if !strings.Contains(string(data), want) { diff --git a/internal/cli/root_test.go b/internal/cli/root_test.go index 4905fb9..6fb037f 100644 --- a/internal/cli/root_test.go +++ b/internal/cli/root_test.go @@ -80,7 +80,7 @@ func TestRunGenerateStormWritesMarkdownReport(t *testing.T) { t.Fatalf("Run() error = %v", err) } assertFileContains(t, outPath, "# Daily Report") - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "storm", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "storm", "2026-05-29", "data_package.*.yaml") assertFileContains(t, dataPackagePath, "id: storm") assertFileContains(t, dataPackagePath, "prompt_id: weather.storm_report") } @@ -99,10 +99,10 @@ func TestRunGenerateTomorrowWritesMarkdownReport(t *testing.T) { t.Fatalf("Run() error = %v", err) } assertFileContains(t, outPath, "# Saturday's Weather") - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "data_package.*.yaml") assertFileContains(t, dataPackagePath, "id: tomorrow") assertFileContains(t, dataPackagePath, "tomorrow_planning:") - reportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "tomorrow", "*.md") + reportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "tomorrow", "2026-05-30", "report.*.md") if !strings.Contains(filepath.Base(reportPath), "tomorrow") { t.Fatalf("managed report = %q, want tomorrow report", reportPath) } @@ -119,8 +119,8 @@ func TestRunEveningGeneratesTomorrowReport(t *testing.T) { if err != nil { t.Fatalf("Run() error = %v", err) } - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "*.data_package.yaml") - reportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "tomorrow", "*.md") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "data_package.*.yaml") + reportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "tomorrow", "2026-05-30", "report.*.md") if !strings.Contains(filepath.Base(reportPath), "tomorrow") { t.Fatalf("managed report = %q, want only tomorrow report", reportPath) } @@ -140,7 +140,7 @@ func TestRunGenerateThreeDayWritesMarkdownReport(t *testing.T) { t.Fatalf("Run() error = %v", err) } assertFileContains(t, outPath, "# Daily Report") - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-29", "data_package.*.yaml") assertFileContains(t, dataPackagePath, "id: three_day") assertFileContains(t, dataPackagePath, "derived_daypart_summaries:") } @@ -159,7 +159,7 @@ func TestRunGenerateWeekendWritesMarkdownReport(t *testing.T) { t.Fatalf("Run() error = %v", err) } assertFileContains(t, outPath, "# Daily Report") - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-29", "data_package.*.yaml") assertFileContains(t, dataPackagePath, "id: weekend") assertFileContains(t, dataPackagePath, "derived_daypart_summaries:") } @@ -175,11 +175,11 @@ func TestRunMorningGeneratesTodayAndTomorrow(t *testing.T) { if err != nil { t.Fatalf("Run() error = %v", err) } - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "*.data_package.yaml") - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-29", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-29", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "*.data_package.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "data_package.*.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-29", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-29", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "data_package.*.yaml") } func TestRunMorningReportsPartialFailureAndContinues(t *testing.T) { @@ -207,8 +207,8 @@ func TestRunMorningReportsPartialFailureAndContinues(t *testing.T) { if !strings.Contains(output.stderr, "status=failed") || !strings.Contains(output.stderr, "status=succeeded") { t.Fatalf("stderr missing structured report logs:\n%s", output.stderr) } - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "*.data_package.yaml") - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "*.data_package.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "data_package.*.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-05-30", "data_package.*.yaml") } func TestBatchOutputIncludesTopLevelNotificationDetails(t *testing.T) { @@ -517,11 +517,11 @@ func TestRunMorningGeneratesTodayAndTomorrowOnSunday(t *testing.T) { if err != nil { t.Fatalf("Run() error = %v", err) } - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-31", "*.data_package.yaml") - _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-06-01", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-31", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-31", "*.data_package.yaml") - noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-31", "*.data_package.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-31", "data_package.*.yaml") + _ = oneArtifact(t, fixture.workspaceRoot, "data-packages", "tomorrow", "2026-06-01", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "three-day", "2026-05-31", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "weekend", "2026-05-31", "data_package.*.yaml") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-31", "data_package.*.yaml") } func TestRunGenerateDailyWritesMarkdownReport(t *testing.T) { @@ -548,7 +548,7 @@ func TestRunGenerateDailyWritesMarkdownReport(t *testing.T) { if !strings.Contains(string(report), "# Friday's Weather") { t.Fatalf("report output missing markdown:\n%s", string(report)) } - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "data_package.*.yaml") data, err := os.ReadFile(dataPackagePath) if err != nil { t.Fatalf("read managed data package: %v", err) @@ -563,7 +563,7 @@ func TestRunGenerateDailyWritesMarkdownReport(t *testing.T) { !strings.Contains(string(data), "timezone: UTC") { t.Fatalf("data package missing configured location with overridden timezone:\n%s", string(data)) } - preflightPath := oneArtifact(t, fixture.workspaceRoot, "preflight", "daily", "2026-05-29", "*.render.json") + preflightPath := oneArtifact(t, fixture.workspaceRoot, "preflight", "daily", "2026-05-29", "render.*.json") preflight, err := os.ReadFile(preflightPath) if err != nil { t.Fatalf("read preflight: %v", err) @@ -571,11 +571,11 @@ func TestRunGenerateDailyWritesMarkdownReport(t *testing.T) { if !strings.Contains(string(preflight), `ok`) { t.Fatalf("preflight missing fake render output:\n%s", string(preflight)) } - _ = oneArtifact(t, fixture.workspaceRoot, "reports", "daily", "*.md") - rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "*.generated_text.raw.json") - validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "*.generated_text.json") - renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "*.render_context.json") - metadataPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "*.metadata.json") + _ = oneArtifact(t, fixture.workspaceRoot, "reports", "daily", "2026-05-29", "report.*.md") + rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "generated_text_raw.*.json") + validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "generated_text.*.json") + renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "render_context.*.json") + metadataPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "daily", "2026-05-29", "metadata.*.json") assertFileContains(t, rawGeneratedTextPath, `"summary": "Showers are possible during the selected day."`) assertFileContains(t, validatedGeneratedTextPath, `"summary":"Showers are possible during the selected day."`) assertFileContains(t, renderContextPath, `"Title": "Friday's Weather"`) @@ -611,7 +611,7 @@ func TestRunGenerateTodayWritesGeneratedTextReport(t *testing.T) { t.Fatalf("today report output missing %q:\n%s", want, string(report)) } } - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "data_package.*.yaml") dataPackage, err := os.ReadFile(dataPackagePath) if err != nil { t.Fatalf("read managed data package: %v", err) @@ -621,11 +621,11 @@ func TestRunGenerateTodayWritesGeneratedTextReport(t *testing.T) { !strings.Contains(string(dataPackage), "today_planning:") { t.Fatalf("data package output missing Today content:\n%s", string(dataPackage)) } - noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "*.data_package.yaml") - rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "*.generated_text.raw.json") - validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "*.generated_text.json") - renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "*.render_context.json") - managedReportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "today", "*.md") + noArtifacts(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "data_package.*.yaml") + rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "generated_text_raw.*.json") + validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "generated_text.*.json") + renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "today", "2026-05-29", "render_context.*.json") + managedReportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "today", "2026-05-29", "report.*.md") assertFileContains(t, rawGeneratedTextPath, `"summary": "Today starts with showers before improving."`) assertFileContains(t, validatedGeneratedTextPath, `"summary":"Today starts with showers before improving."`) assertFileContains(t, renderContextPath, `"Title": "Today's Weather"`) @@ -661,7 +661,7 @@ func TestRunGenerateHourlyWritesGeneratedTextReport(t *testing.T) { t.Fatalf("report output missing %q:\n%s", want, string(report)) } } - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "hourly", "2026-05-29", "*.data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "hourly", "2026-05-29", "data_package.*.yaml") dataPackage, err := os.ReadFile(dataPackagePath) if err != nil { t.Fatalf("read managed data package: %v", err) @@ -671,10 +671,10 @@ func TestRunGenerateHourlyWritesGeneratedTextReport(t *testing.T) { !strings.Contains(string(dataPackage), "hourly_forecast:") { t.Fatalf("data package output missing hourly content:\n%s", string(dataPackage)) } - rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "*.generated_text.raw.json") - validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "*.generated_text.json") - renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "*.render_context.json") - managedReportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "hourly", "*.md") + rawGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "generated_text_raw.*.json") + validatedGeneratedTextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "generated_text.*.json") + renderContextPath := oneArtifact(t, fixture.workspaceRoot, "snapshots", "hourly", "2026-05-29", "render_context.*.json") + managedReportPath := oneArtifact(t, fixture.workspaceRoot, "reports", "hourly", "2026-05-29", "report.*.md") assertFileContains(t, rawGeneratedTextPath, `"summary": " Storm chances increase through late morning. "`) assertFileContains(t, validatedGeneratedTextPath, `"summary":"Storm chances increase through late morning."`) assertFileContains(t, renderContextPath, `"Report": {`) @@ -699,8 +699,8 @@ func TestRunInspectTodayArtifacts(t *testing.T) { if err != nil { t.Fatalf("Run(generate) error = %v", err) } - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "*.data_package.yaml") - runID := strings.TrimSuffix(filepath.Base(dataPackagePath), ".data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "today", "2026-05-29", "data_package.*.yaml") + runID := runIDFromDataPackagePath(t, dataPackagePath) stdout.Reset() err = runner.Run(context.Background(), []string{"inspect", "reports", "--config", fixture.configPath, "--limit", "1"}, &stdout, &stderr) @@ -744,8 +744,8 @@ func TestRunInspectGeneratedArtifacts(t *testing.T) { if err != nil { t.Fatalf("Run(generate) error = %v", err) } - dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "*.data_package.yaml") - runID := strings.TrimSuffix(filepath.Base(dataPackagePath), ".data_package.yaml") + dataPackagePath := oneArtifact(t, fixture.workspaceRoot, "data-packages", "daily", "2026-05-29", "data_package.*.yaml") + runID := runIDFromDataPackagePath(t, dataPackagePath) stdout.Reset() err = runner.Run(context.Background(), []string{"inspect", "reports", "--config", fixture.configPath, "--limit", "1"}, &stdout, &stderr) @@ -1286,6 +1286,16 @@ func noArtifacts(t *testing.T, root string, parts ...string) { } } +func runIDFromDataPackagePath(t *testing.T, path string) string { + t.Helper() + base := filepath.Base(path) + runID := strings.TrimSuffix(strings.TrimPrefix(base, "data_package."), ".yaml") + if runID == base || runID == "" { + t.Fatalf("data package path = %q, want data_package..yaml", path) + } + return runID +} + func firstLineWithPrefix(text string, prefix string) string { for _, line := range strings.Split(text, "\n") { if strings.HasPrefix(line, prefix) {