Fix PromptKit inspection reporter assertions
This commit is contained in:
@@ -255,7 +255,7 @@ func TestCatalogCommandTreesAreIndependentAndOmitShow(t *testing.T) {
|
||||
app := newPromptTestApp(t, test.cmd)
|
||||
var output bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"help", "promptkit", "list"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||
if outcome.Kind != commandkit.OutcomeSuccess || !strings.Contains(output.String(), "list") || !strings.Contains(output.String(), test.want) || strings.Contains(output.String(), test.omit) || strings.Contains(output.String(), "show") {
|
||||
if outcome.Kind != commandkit.OutcomeSuccess || !strings.Contains(output.String(), "list") || !strings.Contains(output.String(), test.want) || strings.Contains(output.String(), "\n "+test.omit+" ") || strings.Contains(output.String(), "\n show ") {
|
||||
t.Fatalf("catalog-only help = (%#v, %q)", outcome, output.String())
|
||||
}
|
||||
})
|
||||
@@ -714,7 +714,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(t *testing.T
|
||||
}, providerErr
|
||||
}}))
|
||||
var output, diagnosticOutput bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"--verbose", "promptkit", "list", "prompts"}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
outcome := app.Execute(context.Background(), []string{"promptkit", "list", "prompts", "--verbose"}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
if outcome.Kind != commandkit.OutcomeOperational || !errors.Is(outcome.Cause, providerErr) {
|
||||
t.Fatalf("provider failure outcome = %#v", outcome)
|
||||
}
|
||||
@@ -731,7 +731,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(t *testing.T
|
||||
}}))
|
||||
output.Reset()
|
||||
diagnosticOutput.Reset()
|
||||
outcome = canceled.Execute(ctx, []string{"--verbose", "promptkit", "list", "prompts"}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
outcome = canceled.Execute(ctx, []string{"promptkit", "list", "prompts", "--verbose"}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
if outcome.Kind != commandkit.OutcomeOperational || !errors.Is(outcome.Cause, context.Canceled) || !strings.Contains(diagnosticOutput.String(), "catalog warning") || output.Len() != 0 {
|
||||
t.Fatalf("post-provider cancellation outcome = %#v output=%q err=%q", outcome, output.String(), diagnosticOutput.String())
|
||||
}
|
||||
@@ -774,7 +774,7 @@ func TestCatalogAndInspectionRespectSuccessfulReportingModes(t *testing.T) {
|
||||
app := newPromptTestApp(t, Command(suite))
|
||||
args := []string{"promptkit", "list", "prompts"}
|
||||
if mode != "ordinary" {
|
||||
args = append([]string{"--" + mode}, args...)
|
||||
args = append(args, "--"+mode)
|
||||
}
|
||||
var output, diagnosticOutput bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), args, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
@@ -796,7 +796,7 @@ func TestCatalogAndInspectionRespectSuccessfulReportingModes(t *testing.T) {
|
||||
diagnosticOutput.Reset()
|
||||
args = []string{"promptkit", "show", "prompt", "briefing"}
|
||||
if mode != "ordinary" {
|
||||
args = append([]string{"--" + mode}, args...)
|
||||
args = append(args, "--"+mode)
|
||||
}
|
||||
outcome = app.Execute(context.Background(), args, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
if outcome.Kind != commandkit.OutcomeSuccess || calls != 2 {
|
||||
@@ -824,7 +824,7 @@ func TestQuietInspectionStillFindsReportEncodingFailure(t *testing.T) {
|
||||
}}))
|
||||
result := &countingWriter{}
|
||||
var diagnosticOutput bytes.Buffer
|
||||
outcome := app.Execute(context.Background(), []string{"--quiet", "promptkit", "show", "profile", "broken"}, commandkit.Streams{Out: result, Err: &diagnosticOutput})
|
||||
outcome := app.Execute(context.Background(), []string{"promptkit", "show", "profile", "broken", "--quiet"}, commandkit.Streams{Out: result, Err: &diagnosticOutput})
|
||||
if !called || result.calls != 0 {
|
||||
t.Fatalf("quiet rendering called=%t destination writes=%d", called, result.calls)
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ func TestNativeLookupErrorsAndBlankIDsReachCallbacks(t *testing.T) {
|
||||
}
|
||||
output.Reset()
|
||||
diagnosticOutput.Reset()
|
||||
outcome = app.Execute(context.Background(), []string{"promptkit", "show", "prompt", ""}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
outcome = app.Execute(context.Background(), []string{"promptkit", "show", "prompt", "", "--verbose"}, commandkit.Streams{Out: &output, Err: &diagnosticOutput})
|
||||
if outcome.Kind != commandkit.OutcomeOperational || !errors.Is(outcome.Cause, nativeErr) || calls != 1 || output.Len() != 0 || !strings.Contains(diagnosticOutput.String(), "lookup context") {
|
||||
t.Fatalf("native lookup failure = (%#v, calls=%d, out=%q, err=%q)", outcome, calls, output.String(), diagnosticOutput.String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user