Migrate PromptKit reports to shared rendering
This commit is contained in:
@@ -202,7 +202,7 @@ func TestRequirementsCommandUsageFailuresPrecedeApplicationPreparation(t *testin
|
||||
}{
|
||||
{name: "missing operand", args: []string{"promptkit", "requirements", "show"}},
|
||||
{name: "extra operand", args: []string{"promptkit", "requirements", "show", "briefing", "extra"}},
|
||||
{name: "unsupported format", args: []string{"promptkit", "requirements", "show", "briefing", "--format", "text"}},
|
||||
{name: "unsupported format", args: []string{"promptkit", "requirements", "show", "briefing", "--format", "invalid"}},
|
||||
{name: "malformed variable followed by valid assignment", args: []string{"promptkit", "requirements", "show", "briefing", "--var", "broken", "--var", "mode=full"}},
|
||||
{name: "no built-in scope", args: []string{"promptkit", "requirements", "show", "briefing", "--scope", "all"}},
|
||||
{name: "malformed variable on help", args: []string{"help", "promptkit", "requirements", "show", "--var", "broken"}},
|
||||
@@ -402,7 +402,7 @@ func TestDiscoveryCommandsForwardFiltersAndRenderCollections(t *testing.T) {
|
||||
if outcome.Kind != commandkit.OutcomeSuccess || backendRequest.Filter.Mode != promptkit.NamespaceAll {
|
||||
t.Fatalf("backend list outcome/filter = (%#v, %#v)", outcome, backendRequest.Filter)
|
||||
}
|
||||
outcome, output = run("promptkit", "list", "namespaces", "--kind", "prompt", "--kind", "backend")
|
||||
outcome, output = run("promptkit", "list", "namespaces", "--kind", "prompt", "--kind", "backend", "--format=yaml")
|
||||
if outcome.Kind != commandkit.OutcomeSuccess || !reflect.DeepEqual(namespaceRequest.Kinds, []promptkit.ResourceKind{promptkit.ResourcePrompt, promptkit.ResourceBackend}) {
|
||||
t.Fatalf("namespace list outcome/kinds = (%#v, %#v)", outcome, namespaceRequest.Kinds)
|
||||
}
|
||||
@@ -460,7 +460,7 @@ func TestCatalogListUsesPreparedInputAndPreflightsFormat(t *testing.T) {
|
||||
}
|
||||
app := newPromptTestApp(t, Command(suite))
|
||||
var output bytes.Buffer
|
||||
invalid := app.Execute(context.Background(), []string{"promptkit", "list", "prompts", "--format", "text"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
invalid := app.Execute(context.Background(), []string{"promptkit", "list", "prompts", "--format", "invalid"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if invalid.Kind != commandkit.OutcomeUsage || newInputCalls != 0 || newStateCalls != 0 || providerCalls != 0 || output.Len() != 0 {
|
||||
t.Fatalf("invalid format preflight = %#v, factories/providers=%d/%d/%d output=%q", invalid, newInputCalls, newStateCalls, providerCalls, output.String())
|
||||
}
|
||||
@@ -800,7 +800,7 @@ func TestCatalogAndInspectionRespectSuccessfulReportingModes(t *testing.T) {
|
||||
if output.Len() != 0 {
|
||||
t.Fatalf("quiet inspection wrote result output %q", output.String())
|
||||
}
|
||||
} else if !strings.Contains(output.String(), "Prompt ID: \"briefing\"") {
|
||||
} else if !strings.Contains(output.String(), "id: briefing") {
|
||||
t.Fatalf("%s inspection omitted result: %q", mode, output.String())
|
||||
}
|
||||
})
|
||||
@@ -1011,7 +1011,7 @@ func TestPromptCatalogYAMLPreservesSchemaStringsAndOrder(t *testing.T) {
|
||||
{ID: "001"},
|
||||
{ID: " briefing "},
|
||||
}
|
||||
output, err := encodePromptCatalog(want)
|
||||
output, err := renderTestYAML(promptCatalogReport(want))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1038,10 +1038,12 @@ func TestCatalogYAMLEncodersRenderNilAndEmptyInventoriesAsSequences(t *testing.T
|
||||
name string
|
||||
data func() ([]byte, error)
|
||||
}{
|
||||
{name: "nil prompts", data: func() ([]byte, error) { return encodePromptCatalog(nil) }},
|
||||
{name: "empty prompts", data: func() ([]byte, error) { return encodePromptCatalog(make([]promptkit.PromptIdentity, 0)) }},
|
||||
{name: "nil profiles", data: func() ([]byte, error) { return encodeProfileCatalog(nil) }},
|
||||
{name: "empty profiles", data: func() ([]byte, error) { return encodeProfileCatalog(make([]string, 0)) }},
|
||||
{name: "nil prompts", data: func() ([]byte, error) { return renderTestYAML(promptCatalogReport(nil)) }},
|
||||
{name: "empty prompts", data: func() ([]byte, error) {
|
||||
return renderTestYAML(promptCatalogReport(make([]promptkit.PromptIdentity, 0)))
|
||||
}},
|
||||
{name: "nil profiles", data: func() ([]byte, error) { return renderTestYAML(stringCatalogReport(nil)) }},
|
||||
{name: "empty profiles", data: func() ([]byte, error) { return renderTestYAML(stringCatalogReport(make([]string, 0))) }},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
output, err := test.data()
|
||||
@@ -1057,7 +1059,7 @@ func TestCatalogYAMLEncodersRenderNilAndEmptyInventoriesAsSequences(t *testing.T
|
||||
|
||||
func TestProfileCatalogYAMLPreservesStringValuesAndOrder(t *testing.T) {
|
||||
want := []string{" default ", "001", "same", "same"}
|
||||
output, err := encodeProfileCatalog(want)
|
||||
output, err := renderTestYAML(stringCatalogReport(want))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1077,7 +1079,7 @@ func TestProfileCatalogYAMLPreservesStringValuesAndOrder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRequirementsReportRendersEmptyInventoriesAndFalseValues(t *testing.T) {
|
||||
output, err := encodePromptYAMLBytes(requirementsReportFromInspection(&promptkit.RequirementInspection{}))
|
||||
output, err := renderTestYAML(requirementsReportFromInspection(&promptkit.RequirementInspection{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -1135,7 +1137,7 @@ func TestRequirementsReportPreservesNativeFieldsAndMetadata(t *testing.T) {
|
||||
for _, complete := range []bool{true, false} {
|
||||
t.Run(map[bool]string{true: "complete", false: "partial"}[complete], func(t *testing.T) {
|
||||
inspection.Complete = complete
|
||||
output, err := encodePromptYAMLBytes(requirementsReportFromInspection(inspection))
|
||||
output, err := renderTestYAML(requirementsReportFromInspection(inspection))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user