From 25b8b4d34b3b09f2df944de21ba3741069bf2963 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 10 Apr 2020 12:47:35 +0200 Subject: [PATCH] Skip testing evcc.dist.yaml on ci (#27) --- cmd/config_test.go | 53 +++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/cmd/config_test.go b/cmd/config_test.go index 7d312e08b..b89be3783 100644 --- a/cmd/config_test.go +++ b/cmd/config_test.go @@ -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) -}