Preflight batch output destinations
This commit is contained in:
@@ -59,6 +59,42 @@ func TestRunBatchDetailedNotifiesOnlyAfterAllOutputsExist(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunBatchDetailedPreflightsAllOutputPaths(t *testing.T) {
|
||||
bundle := generationBundle(t)
|
||||
bundle.Hourly.Periods = bundle.Hourly.Periods[:1]
|
||||
outputDir := t.TempDir()
|
||||
if err := os.Mkdir(filepath.Join(outputDir, "tomorrow.md"), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
todayPath := filepath.Join(outputDir, "today.md")
|
||||
const previousReport = "previous report"
|
||||
if err := os.WriteFile(todayPath, []byte(previousReport), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
executor := &generationExecutor{}
|
||||
promptInspectedBeforeCollection := false
|
||||
collector := &generationCollector{
|
||||
bundle: &bundle,
|
||||
beforeRun: func() {
|
||||
promptInspectedBeforeCollection = executor.promptInspections > 0
|
||||
},
|
||||
}
|
||||
result, err := RunBatchDetailed(context.Background(), BatchRequest{
|
||||
Config: generationDistributorConfig(), Batch: BatchMorning,
|
||||
Now: generationTime("2026-05-29T08:30:00-05:00"), WorkingDir: t.TempDir(), OutputDir: outputDir,
|
||||
Collector: collector, Executor: executor, Notifier: &generationNotifier{},
|
||||
})
|
||||
if err == nil || result != nil || !collector.called || !promptInspectedBeforeCollection || executor.called {
|
||||
t.Fatalf("RunBatchDetailed() result/error/collection/inspection/execution = %#v/%v/%t/%t/%t", result, err, collector.called, promptInspectedBeforeCollection, executor.called)
|
||||
}
|
||||
if data, readErr := os.ReadFile(todayPath); readErr != nil || string(data) != previousReport {
|
||||
t.Fatalf("earlier output = %q, error = %v", data, readErr)
|
||||
}
|
||||
if info, statErr := os.Stat(filepath.Join(outputDir, "tomorrow.md")); statErr != nil || !info.IsDir() {
|
||||
t.Fatalf("blocked output info/error = %#v/%v", info, statErr)
|
||||
}
|
||||
}
|
||||
|
||||
func generationDistributorConfig() config.Config {
|
||||
cfg := generationConfig()
|
||||
cfg.Notify.Distributor.Enabled = true
|
||||
|
||||
Reference in New Issue
Block a user