package action import ( "testing" "github.com/cnachtigall/heatwave-autopilot/internal/heat" "github.com/cnachtigall/heatwave-autopilot/internal/risk" ) func TestBuildTimeline_24Slots(t *testing.T) { contexts := make([]HourContext, 24) for i := range contexts { contexts[i] = HourContext{ Hour: i, TempC: 20 + float64(i), RiskLevel: risk.Low, BudgetStatus: heat.Comfortable, IsDay: i >= 6 && i < 21, } } actions := []Action{ {ID: "test_action", When: TimeCondition{MinTempC: 30}, Impact: ImpactHigh, Effort: EffortNone}, } slots := BuildTimeline(contexts, actions) if len(slots) != 24 { t.Fatalf("slots = %d, want 24", len(slots)) } // Check hour assignment for i, s := range slots { if s.Hour != i { t.Errorf("slot[%d].Hour = %d, want %d", i, s.Hour, i) } if s.TempC != 20+float64(i) { t.Errorf("slot[%d].TempC = %v, want %v", i, s.TempC, 20+float64(i)) } } // test_action matches hours with temp >= 30 (hours 10-23) for i, s := range slots { if i >= 10 && len(s.Actions) == 0 { t.Errorf("slot[%d] should have actions (temp=%v)", i, s.TempC) } if i < 10 && len(s.Actions) > 0 { t.Errorf("slot[%d] should not have actions (temp=%v)", i, s.TempC) } } }