Upgrade spf13/viper (#2754)

Build tags enforce use go gopkgk.in/yaml/v3 instead of v2
This commit is contained in:
andig 2022-03-02 13:01:20 +01:00 • committed by GitHub
parent 0ff07da905
commit 617e42aad8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 13 deletions

37
cmd/setup_test.go Normal file
View file

@ -0,0 +1,37 @@
package cmd
import (
"strings"
"testing"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core"
"github.com/evcc-io/evcc/util"
"github.com/spf13/viper"
)
const sample = `
loadpoints:
- mode: off
`
func TestYamlOff(t *testing.T) {
var conf config
viper.SetConfigType("yaml")
if err := viper.ReadConfig(strings.NewReader(sample)); 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], &lp); err != nil {
t.Error(err)
}
if lp.Mode != api.ModeOff {
t.Errorf("expected `off`, got %s", lp.Mode)
}
}