feat: validate configuration on startup, fail fast on bad config (closes #52) #53
@@ -395,6 +395,25 @@ func TestExplicitNullValueAbortsStartup(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestExplicitlyEmptyDBURLAbortsStartup verifies that db_url set to an
|
||||
// empty string aborts startup: the derived file:...state.sqlite3 URL is
|
||||
// a default, and defaults apply only to omitted keys. This matches
|
||||
// state_dir, where an explicitly empty value already aborts.
|
||||
func TestExplicitlyEmptyDBURLAbortsStartup(t *testing.T) {
|
||||
yamlContent := "signing_key: " + validTestSigningKey + "\ndb_url: \"\"\n"
|
||||
|
||||
c, err := configFromYAML(t, yamlContent)
|
||||
if err == nil {
|
||||
t.Fatalf("explicitly empty db_url must abort startup, got config: %+v", c)
|
||||
}
|
||||
|
||||
t.Logf("got expected error: %v", err)
|
||||
|
||||
if !strings.Contains(err.Error(), "db_url") {
|
||||
t.Errorf("error %q does not name the offending key db_url", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownTopLevelKeyAbortsStartup(t *testing.T) {
|
||||
yamlContent := `signing_key: ` + validTestSigningKey + `
|
||||
whitelist_hosts:
|
||||
|
||||
Reference in New Issue
Block a user