Better error messages for missing DB config values (#101)

* Better error messages for missing DB config values

* Make linter happy
This commit is contained in:
Joona Hoikkala
2018-08-12 19:48:39 +03:00
committed by GitHub
parent 856cc05881
commit ec013c0f25
2 changed files with 39 additions and 1 deletions

View File

@ -127,3 +127,25 @@ func TestFileCheckOK(t *testing.T) {
t.Errorf("File should be accessible")
}
}
func TestPrepareConfig(t *testing.T) {
for i, test := range []struct {
input DNSConfig
shoulderror bool
}{
{DNSConfig{Database: dbsettings{Engine: "whatever", Connection: "whatever_too"}}, false},
{DNSConfig{Database: dbsettings{Engine: "", Connection: "whatever_too"}}, true},
{DNSConfig{Database: dbsettings{Engine: "whatever", Connection: ""}}, true},
} {
_, err := prepareConfig(test.input)
if test.shoulderror {
if err == nil {
t.Errorf("Test %d: Expected error with prepareConfig input data [%v]", i, test.input)
}
} else {
if err != nil {
t.Errorf("Test %d: Expected no error with prepareConfig input data [%v]", i, test.input)
}
}
}
}