Tighten workspace artifact path handling
This commit is contained in:
@@ -3346,15 +3346,22 @@ func plannedBatchNotificationReports(t *testing.T, cfg config.Config, batch Batc
|
||||
if err != nil {
|
||||
t.Fatalf("planBatchRun() error = %v", err)
|
||||
}
|
||||
reportDir := filepath.Join(t.TempDir(), "managed-reports")
|
||||
store, err := state.NewFilesystemStore(cfg.Workspace)
|
||||
if err != nil {
|
||||
t.Fatalf("NewFilesystemStore() error = %v", err)
|
||||
}
|
||||
results := make([]BatchReportResult, 0, len(planned))
|
||||
for _, item := range planned {
|
||||
metadata := item.Resolved.Metadata()
|
||||
paths, err := store.Paths(item.Resolved)
|
||||
if err != nil {
|
||||
t.Fatalf("Paths(%s) error = %v", item.Resolved.Definition.ID, err)
|
||||
}
|
||||
results = append(results, BatchReportResult{
|
||||
ReportID: item.Resolved.Definition.ID,
|
||||
RunID: metadata.RunID,
|
||||
Status: "succeeded",
|
||||
ReportPath: filepath.Join(reportDir, string(item.Resolved.Definition.ID), metadata.RunID+".md"),
|
||||
ReportPath: paths.RenderedReport,
|
||||
})
|
||||
}
|
||||
return planned, results
|
||||
|
||||
@@ -83,8 +83,8 @@ func (s *FilesystemStore) Paths(resolved report.Resolved) (ArtifactPaths, error)
|
||||
return ArtifactPaths{}, fmt.Errorf("state store is required")
|
||||
}
|
||||
metadata := resolved.Metadata()
|
||||
if metadata.RunID == "" {
|
||||
return ArtifactPaths{}, fmt.Errorf("run id is required")
|
||||
if err := validatePathSegment("run id", metadata.RunID); err != nil {
|
||||
return ArtifactPaths{}, err
|
||||
}
|
||||
group := resolved.Definition.ArtifactGroup
|
||||
if group == "" {
|
||||
|
||||
@@ -69,6 +69,20 @@ func TestDailyPathsUseRunIDValidDateDisambiguator(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPathsRejectRunIDPathSeparators(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
resolved := resolveDailyAt(t, "2026-05-29T05:00:00-05:00")
|
||||
resolved.Definition.ID = report.ID("daily/bad")
|
||||
|
||||
_, err := store.Paths(resolved)
|
||||
if err == nil {
|
||||
t.Fatal("Paths() error = nil, want invalid run id error")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "run id must not contain path separators") {
|
||||
t.Fatalf("error = %q, want run id path separator context", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestBatchDistributorNotificationPathUsesWorkspaceBatchDateAndRunID(t *testing.T) {
|
||||
store := newTestStore(t)
|
||||
location := mustLoadStateLocation(t, "America/Chicago")
|
||||
|
||||
Reference in New Issue
Block a user