Fix to ensure unique document IDs when batch reports are generated
This commit is contained in:
@@ -27,12 +27,12 @@ func TestPathsUseRunIDAndWorkspace(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, want := range []string{
|
||||
filepath.Join("snapshots", "daily", "2026-05-29", "20260529T100000.000000000Z_daily.modules.json"),
|
||||
filepath.Join("snapshots", "daily", "2026-05-29", "20260529T100000.000000000Z_daily.metadata.json"),
|
||||
filepath.Join("data-packages", "daily", "2026-05-29", "20260529T100000.000000000Z_daily.data_package.yaml"),
|
||||
filepath.Join("preflight", "daily", "2026-05-29", "20260529T100000.000000000Z_daily.render.json"),
|
||||
filepath.Join("notifications", "daily", "2026-05-29", "20260529T100000.000000000Z_daily.distributor.json"),
|
||||
filepath.Join("reports", "daily", "20260529T100000.000000000Z_daily.md"),
|
||||
filepath.Join("snapshots", "daily", "2026-05-29", "20260529T100000.000000000Z_daily_2026-05-29.modules.json"),
|
||||
filepath.Join("snapshots", "daily", "2026-05-29", "20260529T100000.000000000Z_daily_2026-05-29.metadata.json"),
|
||||
filepath.Join("data-packages", "daily", "2026-05-29", "20260529T100000.000000000Z_daily_2026-05-29.data_package.yaml"),
|
||||
filepath.Join("preflight", "daily", "2026-05-29", "20260529T100000.000000000Z_daily_2026-05-29.render.json"),
|
||||
filepath.Join("notifications", "daily", "2026-05-29", "20260529T100000.000000000Z_daily_2026-05-29.distributor.json"),
|
||||
filepath.Join("reports", "daily", "20260529T100000.000000000Z_daily_2026-05-29.md"),
|
||||
} {
|
||||
if !strings.Contains(pathsString(paths), want) {
|
||||
t.Fatalf("paths = %#v, want component %q", paths, want)
|
||||
@@ -40,6 +40,35 @@ func TestPathsUseRunIDAndWorkspace(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDailyPathsUseRunIDValidDateDisambiguator(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
first := resolveDailyForDateAt(t, "2026-05-29T05:00:00-05:00", "2026-05-31T12:00:00-05:00")
|
||||
second := resolveDailyForDateAt(t, "2026-05-29T05:00:00-05:00", "2026-06-01T12:00:00-05:00")
|
||||
|
||||
firstPaths, err := store.Paths(first)
|
||||
if err != nil {
|
||||
t.Fatalf("Paths(first) error = %v", err)
|
||||
}
|
||||
secondPaths, err := store.Paths(second)
|
||||
if err != nil {
|
||||
t.Fatalf("Paths(second) error = %v", err)
|
||||
}
|
||||
|
||||
if first.Metadata().RunID == second.Metadata().RunID {
|
||||
t.Fatalf("RunIDs both = %q, want distinct daily run ids", first.Metadata().RunID)
|
||||
}
|
||||
for name, values := range map[string][2]string{
|
||||
"RenderedReport": {firstPaths.RenderedReport, secondPaths.RenderedReport},
|
||||
"Metadata": {firstPaths.Metadata, secondPaths.Metadata},
|
||||
"DataPackage": {firstPaths.DataPackage, secondPaths.DataPackage},
|
||||
"Notification": {firstPaths.Notification, secondPaths.Notification},
|
||||
} {
|
||||
if values[0] == values[1] {
|
||||
t.Fatalf("%s paths both = %q, want distinct daily artifact paths", name, values[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeneratedTextArtifactPathsUseSnapshotTree(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
tests := []struct {
|
||||
@@ -54,7 +83,7 @@ func TestGeneratedTextArtifactPathsUseSnapshotTree(t *testing.T) {
|
||||
resolved: resolveDailyAt(t, "2026-05-29T05:00:00-05:00"),
|
||||
group: "daily",
|
||||
validDate: "2026-05-29",
|
||||
runID: "20260529T100000.000000000Z_daily",
|
||||
runID: "20260529T100000.000000000Z_daily_2026-05-29",
|
||||
},
|
||||
{
|
||||
name: "hourly",
|
||||
@@ -567,19 +596,28 @@ func newTestStore(t *testing.T) *FilesystemStore {
|
||||
}
|
||||
|
||||
func resolveDailyAt(t *testing.T, value string) report.Resolved {
|
||||
t.Helper()
|
||||
return resolveDailyForDateAt(t, value, value)
|
||||
}
|
||||
|
||||
func resolveDailyForDateAt(t *testing.T, nowValue string, dateValue string) report.Resolved {
|
||||
t.Helper()
|
||||
location, err := timeutil.LoadLocation("America/Chicago")
|
||||
if err != nil {
|
||||
t.Fatalf("LoadLocation() error = %v", err)
|
||||
}
|
||||
now, err := time.Parse(time.RFC3339, value)
|
||||
now, err := time.Parse(time.RFC3339, nowValue)
|
||||
if err != nil {
|
||||
t.Fatalf("parse time: %v", err)
|
||||
t.Fatalf("parse now time: %v", err)
|
||||
}
|
||||
date, err := time.Parse(time.RFC3339, dateValue)
|
||||
if err != nil {
|
||||
t.Fatalf("parse date time: %v", err)
|
||||
}
|
||||
resolved, err := report.DefaultRegistry().Resolve(report.Daily, report.ResolveRequest{
|
||||
Now: now,
|
||||
Location: location,
|
||||
Date: now,
|
||||
Date: date,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Resolve() error = %v", err)
|
||||
|
||||
Reference in New Issue
Block a user