test: explicitly empty db_url must abort startup (PR #53 rework)
db_url: "" currently silently derives the state_dir-based sqlite URL, which is a default applied to a SET value; state_dir: "" already aborts. Failing test first, fix follows.
This commit is contained in:
@@ -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) {
|
func TestUnknownTopLevelKeyAbortsStartup(t *testing.T) {
|
||||||
yamlContent := `signing_key: ` + validTestSigningKey + `
|
yamlContent := `signing_key: ` + validTestSigningKey + `
|
||||||
whitelist_hosts:
|
whitelist_hosts:
|
||||||
|
|||||||
Reference in New Issue
Block a user