evcc-io/cmd/setup_test.go
2025-01-31 12:26:23 +01:00

34 lines
665 B
Go

package cmd
import (
"strings"
"testing"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/api/globalconfig"
"github.com/evcc-io/evcc/core"
"github.com/evcc-io/evcc/util"
)
func TestYamlOff(t *testing.T) {
var conf globalconfig.All
viper.SetConfigType("yaml")
if err := viper.ReadConfig(strings.NewReader(`loadpoints:
- mode: off
`)); err != nil {
t.Error(err)
}
if err := viper.UnmarshalExact(&conf); err != nil {
t.Error(err)
}
var lp core.Loadpoint
if err := util.DecodeOther(conf.Loadpoints[0].Other, &lp); err != nil {
t.Error(err)
}
if lp.DefaultMode != api.ModeOff {
t.Errorf("expected `off`, got %s", lp.DefaultMode)
}
}