Add some config tests

Still some more to add
This commit is contained in:
Ian Fijolek
2019-10-03 18:16:03 -07:00
parent 71574dd8a9
commit 5c5388d683
6 changed files with 90 additions and 11 deletions
+30
View File
@@ -0,0 +1,30 @@
package main
import (
"log"
"testing"
)
func TestLoadConfig(t *testing.T) {
cases := []struct {
configPath string
expectErr bool
name string
}{
{"./test/valid-config.yml", false, "Valid config file"},
{"./test/does-not-exist", true, "Invalid config path"},
{"./test/invalid-config-type.yml", true, "Invalid config type for key"},
{"./test/invalid-config-missing-alerts.yml", true, "Invalid config missing alerts"},
}
for _, c := range cases {
log.Printf("Testing case %s", c.name)
_, err := LoadConfig(c.configPath)
hasErr := (err != nil)
if hasErr != c.expectErr {
t.Errorf("LoadConfig(%v), expected=%v actual=%v", c.name, "Err", err)
log.Printf("Case failed: %s", c.name)
}
log.Println("-----")
}
}