forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build tags enforce use go gopkgk.in/yaml/v3 instead of v2
- Loading branch information
Showing
6 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters