Demonstrate PromptKit comparison and catalogs
This commit is contained in:
@@ -34,10 +34,9 @@ func TestComposedApplicationDiffUsesFixturesAndCampaignOverride(t *testing.T) {
|
||||
if outcome.Kind != commandkit.OutcomeSuccess {
|
||||
t.Fatalf("overridden fixture diff outcome = %#v", outcome)
|
||||
}
|
||||
for _, category := range []string{"additions", "changes", "deletions"} {
|
||||
if node := composedReportValue(t, output.Bytes(), category); len(node.Content) != 0 {
|
||||
t.Fatalf("campaign override left %s: %q", category, output.String())
|
||||
}
|
||||
value = composedReportValue(t, output.Bytes(), "changes", "campaigns", "spring", "model")
|
||||
if value == nil || value.Value != "spring-model-after" {
|
||||
t.Fatalf("campaign override spring model = %#v; report %q", value, output.String())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,15 +117,59 @@ func TestComposedPromptKitAndDomainCommandsRemainAvailable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptKitScopeDoesNotSupportConfigurationDiff(t *testing.T) {
|
||||
func TestPromptKitScopeDiffAndCatalogsUseSelectedCampaign(t *testing.T) {
|
||||
app, err := newApp()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var output bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"config", "diff", "--scope", "promptkit"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeUsage || output.Len() != 0 {
|
||||
t.Fatalf("PromptKit diff outcome/output = %#v / %q", outcome, output.String())
|
||||
outcome := app.Execute(context.Background(), []string{"config", "diff", "--scope", "promptkit", "--config", "fixtures/before.yml", "--against-config", "fixtures/after.yml", "--campaign", "spring"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeSuccess {
|
||||
t.Fatalf("PromptKit diff outcome = %#v", outcome)
|
||||
}
|
||||
value := composedReportValue(t, output.Bytes(), "changes", "profiles", "spring", "model")
|
||||
if value == nil || value.Value != "spring-model-after" {
|
||||
t.Fatalf("PromptKit diff spring model = %#v; report %q", value, output.String())
|
||||
}
|
||||
|
||||
output.Reset()
|
||||
outcome = app.Execute(context.Background(), []string{"promptkit", "list", "prompts", "--config", "fixtures/before.yml", "--campaign", "spring"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeSuccess {
|
||||
t.Fatalf("prompt catalog outcome = %#v", outcome)
|
||||
}
|
||||
var prompts []map[string]any
|
||||
if err := yaml.Unmarshal(output.Bytes(), &prompts); err != nil {
|
||||
t.Fatalf("decode prompt catalog %q: %v", output.String(), err)
|
||||
}
|
||||
foundPrompt := false
|
||||
for _, prompt := range prompts {
|
||||
if prompt["id"] == "briefing" && prompt["version"] == "1" {
|
||||
foundPrompt = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !foundPrompt {
|
||||
t.Fatalf("selected prompt identity missing from catalog: %#v", prompts)
|
||||
}
|
||||
|
||||
output.Reset()
|
||||
outcome = app.Execute(context.Background(), []string{"promptkit", "list", "profiles", "--config", "fixtures/after.yml", "--campaign", "autumn", "--format", "yaml"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeSuccess {
|
||||
t.Fatalf("profile catalog outcome = %#v", outcome)
|
||||
}
|
||||
var profiles []string
|
||||
if err := yaml.Unmarshal(output.Bytes(), &profiles); err != nil {
|
||||
t.Fatalf("decode profile catalog %q: %v", output.String(), err)
|
||||
}
|
||||
foundProfile := false
|
||||
for _, profile := range profiles {
|
||||
if profile == "autumn" {
|
||||
foundProfile = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !foundProfile {
|
||||
t.Fatalf("selected profile missing from catalog: %#v", profiles)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user