config: detect duplicate & internal job names at parse time (#908)
Before this PR, config parsing would accept duplicate job names. `zrepl daemon` would later fail to start with a panic. But tools like `zrepl configcheck` would pass. This PR adds a check to ensure job names are unique. Similarly, internal job names were not being rejected by config parsing Move that check to parse-time as well. Last, drive-by change: remove `internal/config/config_include_test.go` introduced in #856 . These aren't necessary because there is already a wildcard test for all valid configs. This PR adds the complimentary "invalid config" wildcard test.
This commit is contained in:
committed by
GitHub
parent
4d6583ea5f
commit
860a9be37f
@@ -45,6 +45,20 @@ func TestSampleConfigsAreParsedWithoutErrors(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestInvalidSampleConfigsFailToParse(t *testing.T) {
|
||||
paths, err := filepath.Glob("./samples/invalid/*/zrepl.yml")
|
||||
require.NoError(t, err, "glob failed")
|
||||
require.NotEmpty(t, paths, "no invalid sample configs found")
|
||||
|
||||
for _, p := range paths {
|
||||
t.Run(p, func(t *testing.T) {
|
||||
_, err := ParseConfig(p)
|
||||
require.Error(t, err, "expected config %s to fail parsing", p)
|
||||
t.Logf("config %s failed as expected: %v", p, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// template must be a template/text template with a single '{{ . }}' as placeholder for val
|
||||
//
|
||||
//nolint:deadcode,unused
|
||||
|
||||
Reference in New Issue
Block a user