chore: add MaxACPower test (#19285)

This commit is contained in:
andig 2025-03-01 12:12:31 +01:00 • committed by GitHub
parent 766194d0c0
commit 59d7bb54ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -4,6 +4,8 @@ type maxpower struct {
MaxACPower float64
}
// var _ api.MaxACPowerGetter = (*maxpower)(nil)
// MaxACPowerDecorator returns the max AC power decorator
func (m *maxpower) Decorator() func() float64 {
if m.MaxACPower == 0 {

30
meter/meter_test.go Normal file
View file

@ -0,0 +1,30 @@
package meter
import (
"context"
"testing"
"github.com/evcc-io/evcc/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestACPower(t *testing.T) {
m, err := NewConfigurableFromConfig(context.TODO(), map[string]any{
"capacity": 23,
"soc": map[string]any{
"source": "const",
"value": 47,
},
"maxacpower": 1000,
"power": map[string]any{
"source": "const",
"value": 1000,
},
})
require.NoError(t, err)
_, ok := m.(api.BatteryCapacity)
assert.True(t, ok, "api.BatteryCapacity")
_, ok = m.(api.MaxACPowerGetter)
assert.True(t, ok, "api.MaxACPowerGetter")
}