fix: unblock first growth report generation

This commit is contained in:
2026-08-21 07:49:04 +08:00
parent e6afaa7a10
commit 927319807b
7 changed files with 67 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
package growth
import (
"bytes"
"encoding/json"
"testing"
"time"
)
@@ -194,6 +196,19 @@ func TestBuildDeterministicReportLimitsAndOrdersOpportunities(t *testing.T) {
}
}
func TestBuildDeterministicReportSerializesEmptyCollectionsAsArrays(t *testing.T) {
report := BuildDeterministicReport(ReportInput{ForecastStart: time.Date(2026, 7, 1, 0, 0, 0, 0, time.UTC), HorizonDays: 90})
encoded, err := json.Marshal(report)
if err != nil {
t.Fatal(err)
}
for _, field := range []string{`"historicalWins":[]`, `"opportunities":[]`, `"risks":[]`, `"fallbackBriefs":[]`} {
if !bytes.Contains(encoded, []byte(field)) {
t.Fatalf("report must encode %s as an array: %s", field, encoded)
}
}
}
func TestFingerprintTreatsEquivalentForecastDatesEqually(t *testing.T) {
tehran, err := time.LoadLocation("Asia/Tehran")
if err != nil {