Strengthen continuation notification ownership coverage
This commit is contained in:
@@ -126,6 +126,9 @@ func TestPreparedNotificationInvalidHandlesAndPreparationOnlyCalls(t *testing.T)
|
||||
if _, err := foreign.RunPrepared(context.Background(), handle); !errors.Is(err, promptkit.ErrInvalidRequest) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := engine.RunPrepared(context.Background(), nil); !errors.Is(err, promptkit.ErrInvalidRequest) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
handle.Discard()
|
||||
if _, err := engine.RunPrepared(context.Background(), handle); !errors.Is(err, promptkit.ErrInvalidRequest) {
|
||||
t.Fatal(err)
|
||||
@@ -136,6 +139,30 @@ func TestPreparedNotificationInvalidHandlesAndPreparationOnlyCalls(t *testing.T)
|
||||
if calls != 0 {
|
||||
t.Fatalf("unexpected notifications=%d", calls)
|
||||
}
|
||||
handle, err = engine.PrepareExecution(context.Background(), req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := engine.RunPrepared(context.Background(), handle); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := engine.RunPrepared(context.Background(), handle); !errors.Is(err, promptkit.ErrInvalidRequest) || calls != 1 {
|
||||
t.Fatalf("reused handle error=%v notifications=%d", err, calls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotificationHoldsAdmission(t *testing.T) {
|
||||
engine := newBackendCapacityEngine(t, observationClientFunc(func(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||
return &promptkit.GenerateResponse{Content: "ok"}, nil
|
||||
}), 1, capacityInt(0), nil)
|
||||
_, err := engine.Run(context.Background(), promptkit.RunRequest{PromptID: "prompt", OnPrepared: func(ctx context.Context, _ promptkit.PreparedRun) {
|
||||
if _, err := engine.Run(ctx, promptkit.RunRequest{PromptID: "prompt"}); !errors.Is(err, promptkit.ErrCapacityExceeded) {
|
||||
t.Errorf("nested admission error=%v", err)
|
||||
}
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNotificationPanicReleasesCapacityAndConsumesHandle(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user