Use native configuration views and shared prompt loading

This commit is contained in:
2026-11-23 03:28:30 +00:00
parent b6693fde73
commit 5e29399705
6 changed files with 49 additions and 130 deletions

View File

@@ -117,3 +117,33 @@ func TestServerBootstrapsBeforeListening(t *testing.T) {
t.Fatalf("bootstrap repeated or leaked: response=%q stdout=%q stderr=%q", body, out.String(), diagnostics.String())
}
}
func TestNativeScopesAndHelpUseSharedLoading(t *testing.T) {
const name = "SCRIPTORIUM_TEST_SCOPE_CREDENTIAL"
t.Setenv(name, "")
root := t.TempDir()
if err := os.Mkdir(filepath.Join(root, "secrets"), 0700); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(root, "secrets", name), []byte("dummy"), 0600); err != nil {
t.Fatal(err)
}
path := filepath.Join(root, "app.yml")
if err := os.WriteFile(path, []byte("config: {secrets_dir: secrets, secrets_overwrite: true}\n"), 0600); err != nil {
t.Fatal(err)
}
for _, args := range [][]string{{"config", "scopes"}, {"config", "explain", "--config=" + path}, {"--help"}, {"completion", "bash"}, {"completion", "zsh"}, {"completion", "fish"}} {
var out, diagnostic bytes.Buffer
outcome := Execute(context.Background(), commandkit.Identity{Name: "scriptorium"}, args, &out, &diagnostic)
if outcome.Status != 0 || os.Getenv(name) != "" || strings.Contains(diagnostic.String(), name) {
t.Fatalf("%v: %+v %q", args, outcome, diagnostic.String())
}
}
for _, scope := range []string{"app", "promptkit"} {
var out, diagnostic bytes.Buffer
outcome := Execute(context.Background(), commandkit.Identity{Name: "scriptorium"}, []string{"config", "show", "--scope=" + scope, "--config=" + path, `--set=/promptkit/custom="selected"`}, &out, &diagnostic)
if outcome.Status != 0 || !strings.Contains(out.String(), "selected") || os.Getenv(name) != "dummy" {
t.Fatalf("%s: %+v %q %q", scope, outcome, out.String(), diagnostic.String())
}
}
}