Isolate parsed provider parameters

This commit is contained in:
2026-11-07 15:38:06 +00:00
parent b66d265032
commit c82235100e
6 changed files with 106 additions and 3 deletions

View File

@@ -219,3 +219,33 @@ func TestSmokeAggregateCancellationRetainsPartialResults(t *testing.T) {
t.Fatalf("partial aggregate entries = %#v", document.Tests)
}
}
func TestSmokeAggregateIsolatesProviderParameters(t *testing.T) {
calls := 0
app := newPromptTestApp(t, Command(Suite[struct{}, struct{}]{
SmokeTest: func(_ context.Context, request SmokeRequest, _, _ struct{}) (commandkit.Acquired[*promptkit.SmokeTestReport], error) {
calls++
params := request.Request.Execution.ExtraParams
value := params["nested"].(map[string]any)["array"].([]any)[0].(map[string]any)
if value["number"] != int64(1) {
t.Errorf("call %d: %#v", calls, value)
}
value["number"] = int64(9)
return commandkit.Acquired[*promptkit.SmokeTestReport]{Value: &promptkit.SmokeTestReport{Kind: request.Request.Kind}}, nil
},
}))
outcome := app.Execute(context.Background(), []string{"promptkit", "test", "all", `--llm-extra-params={"nested":{"array":[{"number":1}]}}`}, commandkit.Streams{Out: io.Discard, Err: io.Discard})
if outcome.Kind != commandkit.OutcomeSuccess || calls != 4 {
t.Fatalf("outcome=%#v calls=%d", outcome, calls)
}
}
func TestCopyProviderParamsPreservesEmptyAndNilValues(t *testing.T) {
if copyProviderParams(nil) != nil {
t.Fatal("nil object became non-nil")
}
copied := copyProviderParams(map[string]any{"emptyObject": map[string]any{}, "nilObject": map[string]any(nil), "emptyArray": []any{}, "nilArray": []any(nil), "null": nil, "decimal": float64(1.5)})
if copied["emptyObject"].(map[string]any) == nil || copied["nilObject"].(map[string]any) != nil || copied["emptyArray"].([]any) == nil || copied["nilArray"].([]any) != nil || copied["null"] != nil || copied["decimal"] != float64(1.5) {
t.Fatalf("copied = %#v", copied)
}
}