Validate explanation pointers before loading configuration
This commit is contained in:
@@ -15,6 +15,23 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
func TestExplainRejectsMalformedPointerBeforeLoadingEitherScope(t *testing.T) {
|
||||
for _, scope := range []string{"notarius", "promptkit"} {
|
||||
t.Run(scope, func(t *testing.T) {
|
||||
var stdout, stderr strings.Builder
|
||||
options := commandContractOptions(t)
|
||||
options.LookupEnv = func(string) (string, bool) {
|
||||
t.Fatal("configuration discovery ran for invalid syntax")
|
||||
return "", false
|
||||
}
|
||||
code := RunWithOptions([]string{"config", "explain", "--scope", scope, "--config", filepath.Join(t.TempDir(), "missing.yml"), "/profiles/~2"}, &stdout, &stderr, options)
|
||||
if code != 2 || stdout.Len() != 0 || !strings.Contains(stderr.String(), "canonical JSON Pointer") {
|
||||
t.Fatalf("code=%d stdout=%q stderr=%q", code, stdout.String(), stderr.String())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigKitReadOnlyCommandsLoadImportsAndOverlays(t *testing.T) {
|
||||
t.Parallel()
|
||||
root := t.TempDir()
|
||||
|
||||
Reference in New Issue
Block a user