Add soc push event every 10% charge progress (#2337)

This commit is contained in:
andig 2022-01-20 19:40:49 +01:00 • committed by GitHub
parent 9bb68bd819
commit 479377f0d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 3 deletions

33
core/progress_test.go Normal file
View file

@ -0,0 +1,33 @@
package core
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
)
func TestProgress(t *testing.T) {
p := NewProgress(0, 10)
tc := []struct {
value float64
res bool
}{
{-1, false},
{0, true},
{1, false},
{5, false},
{10, true},
{15, false},
{25, true},
{30, true},
{60, true},
{65, false},
{70, true},
}
for _, tc := range tc {
require.Equal(t, tc.res, p.NextStep(tc.value), fmt.Sprintf("%.0f%%", tc.value))
}
}