Demonstrate PromptKit catalogs and smoke tests

This commit is contained in:
2026-10-17 19:06:05 +00:00
parent 079576361b
commit 35e958c210
4 changed files with 127 additions and 8 deletions

View File

@@ -311,6 +311,45 @@ func TestPromptKitScopeDiffAndCatalogsUseSelectedCampaign(t *testing.T) {
}
}
func TestComposedCatalogsAndSmokeUseInjectedClientOnlyForInference(t *testing.T) {
calls := 0
app, err := newAppWithLLMClient(&exampleLLMClient{calls: &calls})
if err != nil {
t.Fatal(err)
}
commands := [][]string{
{"promptkit", "list", "backends", "--campaign", "spring"},
{"promptkit", "list", "namespaces", "--campaign", "spring"},
{"promptkit", "list", "collections", "--campaign", "spring"},
{"promptkit", "list", "prompts", "--namespace", "field-notes", "--campaign", "spring"},
{"promptkit", "show", "prompt", "briefing", "--campaign", "spring"},
{"promptkit", "requirements", "show", "briefing", "--campaign", "spring"},
}
for _, args := range commands {
var output bytes.Buffer
outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &output, Err: io.Discard})
if outcome.Kind != commandkit.OutcomeSuccess {
t.Errorf("metadata command %q outcome = %#v; output %q", args, outcome, output.String())
}
if output.Len() == 0 {
t.Errorf("metadata command %q produced no report", args)
}
}
if calls != 0 {
t.Fatalf("metadata and requirements commands invoked the LLM client %d times", calls)
}
var output bytes.Buffer
outcome := app.Execute(context.Background(), []string{"promptkit", "test", "all", "--campaign", "spring", "--prompt", "briefing", "--profile", "spring"}, commandkit.Streams{Out: &output, Err: io.Discard})
if output.Len() == 0 || !bytes.Contains(output.Bytes(), []byte("tests:")) {
t.Fatalf("aggregate smoke report missing: outcome=%#v output=%q", outcome, output.String())
}
if calls == 0 {
t.Fatalf("smoke command did not use the injected LLM client: outcome=%#v output=%q", outcome, output.String())
}
}
func composedReportValue(t *testing.T, data []byte, category string, fields ...string) *yaml.Node {
t.Helper()
var document yaml.Node