Verify prepared notification ownership and cleanup
This commit is contained in:
@@ -18,3 +18,25 @@ func TestPreparedNotificationChecksContextBeforeInvocation(t *testing.T) {
|
||||
t.Fatalf("called=%v error=%v", called, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPreparedNotificationPanicClearsClaimedPayload(t *testing.T) {
|
||||
runner := NewRunner(&fakePromptRepo{def: promptDef(domain.FormatText, domain.ValidationNone, 0)},
|
||||
&fakeExecutionProfileRepo{profiles: map[string]*domain.ExecutionProfile{"exec": defaultExecutionProfile()}},
|
||||
defaultArtifactReader(), defaultRenderer(), &fakeLLM{resp: &domain.GenerateResponse{Content: "ok"}}, nil, nil)
|
||||
handle, err := runner.PrepareExecution(context.Background(), domain.RunRequest{PromptID: "p", ProfileID: "exec", Inputs: singleInputRef(), OnPrepared: func(context.Context, *domain.PreparedRun) { panic("notification") }})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
payload := handle.payload
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
t.Error("expected panic")
|
||||
}
|
||||
}()
|
||||
_, _ = runner.RunPrepared(context.Background(), handle)
|
||||
}()
|
||||
if payload.prepared != nil || payload.onPrepared != nil || payload.directKey != "" || handle.payload != nil {
|
||||
t.Fatal("claimed payload retained private state")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user