Complete CommandKit consumer documentation
This commit is contained in:
@@ -250,6 +250,11 @@ func TestPromptKitInspectionSelectionErrorsHelpAndOptionalCapabilities(t *testin
|
||||
if outcome.Kind != commandkit.OutcomeUsage || loaderCalls != beforeMissing {
|
||||
t.Fatalf("missing ID = (%#v, calls=%d), want usage before acquisition", outcome, loaderCalls)
|
||||
}
|
||||
beforeScopeFlag := loaderCalls
|
||||
outcome = app.Execute(context.Background(), []string{"promptkit", "show", "profile", "child", "--scope", "promptkit"}, commandkit.Streams{Out: io.Discard, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeUsage || loaderCalls != beforeScopeFlag {
|
||||
t.Fatalf("definition command accepted --scope: outcome=%#v calls=%d", outcome, loaderCalls)
|
||||
}
|
||||
|
||||
profileOnlyApp, _ := commandkit.New(commandkit.Identity{Name: "profile-only"})
|
||||
if err := commandkit.RegisterPromptKit(profileOnlyApp, commandkit.PromptKitSuite[struct{}]{InspectProfile: func(ctx context.Context, _ commandkit.Selection, _ struct{}, id string) (commandkit.Acquired[*promptkit.ProfileInspection], error) {
|
||||
@@ -362,6 +367,29 @@ func TestPromptKitDirectSuiteRetainsDiagnosticsOnNamedLookupFailure(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptKitInspectionReportsOutputDeliveryFailure(t *testing.T) {
|
||||
engine := promptKitInspectionEngine(t)
|
||||
suite, err := commandkit.NewPromptKitSuite(func(context.Context, commandkit.Selection, struct{}) (*promptkit.Engine, error) {
|
||||
return engine, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
app, _ := commandkit.New(commandkit.Identity{Name: "example"})
|
||||
if err := commandkit.RegisterPromptKit(app, suite); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
writeErr := errors.New("report output failed")
|
||||
outcome := app.Execute(context.Background(), []string{"promptkit", "show", "profile", "child", "--format", "yaml"}, commandkit.Streams{Out: promptKitFailingWriter{err: writeErr}, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeOperational || !outcome.ReportIncomplete || !errors.Is(outcome.DeliveryError, writeErr) {
|
||||
t.Fatalf("promptkit output failure = %#v", outcome)
|
||||
}
|
||||
}
|
||||
|
||||
type promptKitFailingWriter struct{ err error }
|
||||
|
||||
func (writer promptKitFailingWriter) Write([]byte) (int, error) { return 0, writer.err }
|
||||
|
||||
func sortedKeys(values map[string]any) []string {
|
||||
keys := make([]string, 0, len(values))
|
||||
for key := range values {
|
||||
|
||||
Reference in New Issue
Block a user