evcc-io/charger/wallbe_test.go
andig ac9f8bac8a
Fix decorators hiding optional interfaces (#507)
Without this PR, decorating an api.Charger which has additional interfaces removed those interfaces from the decorated charger.
2020-12-07 12:14:49 +01:00

50 lines
903 B
Go

package charger
import (
"testing"
"github.com/andig/evcc/api"
)
func TestWallbeLegacy(t *testing.T) {
wbc, err := NewWallbeFromConfig(map[string]interface{}{"legacy": true})
if err != nil {
t.Error(err)
}
wb, ok := wbc.(*Wallbe)
if !ok {
t.Error("unexpected type")
}
if wb.factor != 1 {
t.Errorf("invalid factor: %d", wb.factor)
}
if _, ok = wbc.(api.ChargeTimer); !ok {
t.Error("missing charge timer api")
}
if _, ok = wbc.(api.Diagnosis); !ok {
t.Error("missing diagnosis api")
}
}
func TestWallbeEx(t *testing.T) {
wbc, err := NewWallbeFromConfig(map[string]interface{}{"legacy": false})
if err != nil {
t.Error(err)
}
if _, ok := wbc.(api.ChargerEx); !ok {
t.Error("missing ChargerEx api")
}
if _, ok := wbc.(api.ChargeTimer); !ok {
t.Error("missing ChargeTimer api")
}
if _, ok := wbc.(api.Diagnosis); !ok {
t.Error("missing Diagnosis api")
}
}