Skip testing evcc.dist.yaml on ci (#27)

This commit is contained in:
andig 2020-04-10 12:47:35 +02:00 • committed by GitHub
parent 8527ddeec7
commit 25b8b4d34b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
}