Skip testing evcc.dist.yaml on ci (#27)
This commit is contained in:
parent
8527ddeec7
commit
25b8b4d34b
1 changed files with 31 additions and 22 deletions
|
|
@ -8,6 +8,37 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// skipCI skips testing if CI is set
|
||||
func skipCI(t *testing.T) {
|
||||
if os.Getenv("CI") != "" {
|
||||
t.Skip("Skipping testing in CI environment")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistConfig(t *testing.T) {
|
||||
skipCI(t)
|
||||
|
||||
file := "../evcc.dist.yaml"
|
||||
yaml, err := os.Open(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
if err := viper.ReadConfig(yaml); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// check config does not contain surplus keys
|
||||
var conf config
|
||||
if err := viper.UnmarshalExact(&conf); err != nil {
|
||||
log.FATAL.Fatalf("config: failed parsing config file %s: %v", cfgFile, err)
|
||||
}
|
||||
|
||||
// check config is valid
|
||||
loadConfig(conf, nil)
|
||||
}
|
||||
|
||||
func TestMeterConfig(t *testing.T) {
|
||||
yaml := `
|
||||
meters:
|
||||
|
|
@ -49,25 +80,3 @@ chargers:
|
|||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDistConfig(t *testing.T) {
|
||||
file := "../evcc.dist.yaml"
|
||||
yaml, err := os.Open(file)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
viper.SetConfigType("yaml")
|
||||
if err := viper.ReadConfig(yaml); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
// check config does not contain surplus keys
|
||||
var conf config
|
||||
if err := viper.UnmarshalExact(&conf); err != nil {
|
||||
log.FATAL.Fatalf("config: failed parsing config file %s: %v", cfgFile, err)
|
||||
}
|
||||
|
||||
// check config is valid
|
||||
loadConfig(conf, nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue