Enhance interrupt test clarity by specifying empty messages for force interrupts
- Updated the test case for force interrupts to clarify that empty messages indicate pure cancellation. - Improved log messages to reflect the change in behavior, ensuring better understanding of context cancellation during tests.
This commit is contained in:
parent
38e8397527
commit
1c11690a65
1 changed files with 5 additions and 4 deletions
|
|
@ -520,10 +520,11 @@ func TestInterruptContext(t *testing.T) {
|
||||||
// Get context before interrupt
|
// Get context before interrupt
|
||||||
interruptCtx := ctx.Interrupt.Context()
|
interruptCtx := ctx.Interrupt.Context()
|
||||||
|
|
||||||
// Send force interrupt
|
// Send force interrupt with empty messages (pure cancellation)
|
||||||
|
// This is the pattern for stopping streaming without appending messages
|
||||||
signal := &InterruptSignal{
|
signal := &InterruptSignal{
|
||||||
Type: InterruptForce,
|
Type: InterruptForce,
|
||||||
Messages: []Message{{Role: RoleUser, Content: "force stop"}},
|
Messages: []Message{}, // Empty messages = pure cancellation
|
||||||
Timestamp: time.Now().UnixMilli(),
|
Timestamp: time.Now().UnixMilli(),
|
||||||
}
|
}
|
||||||
err := SendInterrupt(ctx.ID, signal)
|
err := SendInterrupt(ctx.ID, signal)
|
||||||
|
|
@ -536,9 +537,9 @@ func TestInterruptContext(t *testing.T) {
|
||||||
// The OLD context should be cancelled
|
// The OLD context should be cancelled
|
||||||
select {
|
select {
|
||||||
case <-interruptCtx.Done():
|
case <-interruptCtx.Done():
|
||||||
t.Log("✓ Force interrupt cancelled the old context")
|
t.Log("✓ Force interrupt with empty messages cancelled the old context")
|
||||||
case <-time.After(200 * time.Millisecond):
|
case <-time.After(200 * time.Millisecond):
|
||||||
t.Error("Old context was not cancelled after force interrupt")
|
t.Error("Old context was not cancelled after force interrupt with empty messages")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: IsInterrupted() checks the NEW context (which was recreated)
|
// Note: IsInterrupted() checks the NEW context (which was recreated)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue