Remove recent changes from prompt execution
This commit is contained in:
@@ -612,69 +612,6 @@ func workflowBundlePaths(id report.ID, validDate, runID string) []string {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateDetailedSelectsPriorSnapshotsForRetainedReports(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
kind ReportKind
|
||||
id report.ID
|
||||
date time.Time
|
||||
raw string
|
||||
wantPrior bool
|
||||
wantRecentChanges bool
|
||||
}{
|
||||
{name: "daily", kind: ReportDaily, id: report.Daily, date: workflowTime("2026-05-29T12:00:00-05:00"), raw: validDailyWorkflowJSON(), wantPrior: true, wantRecentChanges: true},
|
||||
{name: "today", kind: ReportToday, id: report.Today, raw: validTodayWorkflowJSON(), wantPrior: true, wantRecentChanges: true},
|
||||
{name: "tomorrow", kind: ReportTomorrow, id: report.Tomorrow, raw: validTomorrowWorkflowJSON(), wantPrior: true, wantRecentChanges: true},
|
||||
{name: "hourly", kind: ReportHourly, id: report.Hourly, raw: validHourlyWorkflowJSON()},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cfg := workflowConfig(t)
|
||||
cfg.Notify.Distributor.Enabled = false
|
||||
definition := report.DefaultRegistry().MustLookup(test.id)
|
||||
firstBundle := workflowBundle(t)
|
||||
setWorkflowTemperatures(&firstBundle, 45)
|
||||
first, err := GenerateDetailed(context.Background(), GenerateRequest{
|
||||
Config: cfg, Report: test.kind, Date: test.date, Now: workflowTime("2026-05-29T08:00:00-05:00"),
|
||||
Collector: &workflowCollector{result: &collect.Result{Bundle: &firstBundle}},
|
||||
Executor: &workflowExecutor{definition: definition, raw: []byte(test.raw)},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("first GenerateDetailed() error = %v", err)
|
||||
}
|
||||
secondBundle := workflowBundle(t)
|
||||
setWorkflowTemperatures(&secondBundle, 85)
|
||||
second, err := GenerateDetailed(context.Background(), GenerateRequest{
|
||||
Config: cfg, Report: test.kind, Date: test.date, Now: workflowTime("2026-05-29T08:30:00-05:00"),
|
||||
Collector: &workflowCollector{result: &collect.Result{Bundle: &secondBundle}},
|
||||
Executor: &workflowExecutor{definition: definition, raw: []byte(test.raw)},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("second GenerateDetailed() error = %v", err)
|
||||
}
|
||||
if test.wantPrior && (second.PriorSnapshot == nil || second.PriorSnapshot.Metadata.RunID != first.Metadata.RunID || second.PriorSnapshot.Metadata.ReportID != test.id) {
|
||||
t.Fatalf("prior snapshot = %#v, want first %s run %q", second.PriorSnapshot, test.id, first.Metadata.RunID)
|
||||
}
|
||||
if !test.wantPrior && second.PriorSnapshot != nil {
|
||||
t.Fatalf("prior snapshot = %#v, want none for non-overlapping rolling window", second.PriorSnapshot)
|
||||
}
|
||||
if (len(second.RecentChanges) > 0) != test.wantRecentChanges {
|
||||
t.Fatalf("recent changes = %#v, want present %t", second.RecentChanges, test.wantRecentChanges)
|
||||
}
|
||||
if (len(second.DataPackage.RecentChanges.Items) > 0) != test.wantRecentChanges {
|
||||
t.Fatalf("data package recent changes = %#v, want present %t", second.DataPackage.RecentChanges.Items, test.wantRecentChanges)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func setWorkflowTemperatures(bundle *weatherdata.Bundle, temperature float64) {
|
||||
for index := range bundle.Hourly.Periods {
|
||||
value := temperature
|
||||
bundle.Hourly.Periods[index].TemperatureF = &value
|
||||
}
|
||||
}
|
||||
|
||||
func workflowConfig(t *testing.T) config.Config {
|
||||
t.Helper()
|
||||
cfg := config.Defaults()
|
||||
|
||||
Reference in New Issue
Block a user