Classify configuration acquisition errors consistently
This commit is contained in:
@@ -60,6 +60,32 @@ func TestMalformedCompanionReturnsInputFailure(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnreadableCompanionReturnsOperationalFailure(t *testing.T) {
|
||||
main := writeRuntimeErrorConfig(t, "profiles: []\n")
|
||||
companion := filepath.Join(filepath.Dir(main), "prompts.yml")
|
||||
if err := os.Chmod(companion, 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.ReadFile(companion); !errors.Is(err, os.ErrPermission) {
|
||||
t.Skipf("file permissions do not prevent reads: %v", err)
|
||||
}
|
||||
transcript := filepath.Join(filepath.Dir(main), "transcript.json")
|
||||
if err := os.WriteFile(transcript, []byte("[]\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, args := range [][]string{
|
||||
{"promptkit", "list", "prompts"},
|
||||
{"config", "show", "--scope", "promptkit"},
|
||||
{"process", transcript},
|
||||
} {
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := Run(context.Background(), append(args, "--config", main), &stdout, &stderr)
|
||||
if code != 1 || !strings.Contains(stderr.String(), "source.permission") || !strings.Contains(stderr.String(), "prompts.yml") || stdout.Len() != 0 {
|
||||
t.Errorf("%v: status=%d want=1 stdout=%q stderr=%q", args, code, stdout.String(), stderr.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourceCommandKeepsCallerCancellationAsFailure(t *testing.T) {
|
||||
main := writeRuntimeErrorConfig(t, "profiles:\n - id: proposal\n model: local-model\n")
|
||||
transcript := filepath.Join(filepath.Dir(main), "transcript.json")
|
||||
|
||||
Reference in New Issue
Block a user