Planner: fix preconditioning creating empty slots (#26448)
This commit is contained in:
parent
0ba228d0a3
commit
8ef3cce10f
2 changed files with 10 additions and 1 deletions
|
|
@ -9,9 +9,18 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/tariff"
|
||||
"github.com/samber/lo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSlitPrecondition(t *testing.T) {
|
||||
clock := clock.NewMock()
|
||||
rr := rates([]float64{1, 2, 3, 4}, clock.Now(), tariff.SlotDuration)
|
||||
rates, precond := splitPreconditionSlots(rr, clock.Now().Add(3*tariff.SlotDuration))
|
||||
assert.Equal(t, rr[0:3], rates, "rates")
|
||||
assert.Equal(t, rr[3:], precond, "precond")
|
||||
}
|
||||
|
||||
func TestSlotHasSuccessor(t *testing.T) {
|
||||
plan := rates([]float64{20, 60, 10, 80, 40, 90}, time.Now(), time.Hour)
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ func splitPreconditionSlots(rates api.Rates, preCondStart time.Time) (api.Rates,
|
|||
}
|
||||
|
||||
// split slot
|
||||
if !r.Start.After(preCondStart) {
|
||||
if r.Start.Before(preCondStart) {
|
||||
// keep the first part of the slot
|
||||
res = append(res, api.Rate{
|
||||
Start: r.Start,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue