Preserve operational timeouts when selecting run failures
This commit is contained in:
25
internal/framework/pipeline/error_selection_test.go
Normal file
25
internal/framework/pipeline/error_selection_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/promptkit"
|
||||
)
|
||||
|
||||
func TestRunErrorSelectionPreservesOperationalDeadlines(t *testing.T) {
|
||||
for _, first := range []error{context.DeadlineExceeded, fmt.Errorf("%w: %w", promptkit.ErrOperationTimeout, context.DeadlineExceeded)} {
|
||||
later := errors.New("later failure")
|
||||
got := selectRunError(context.Background(), []orderedRunError{{lane: 1, err: later}, {lane: 0, err: first}, {lane: -1, err: context.Canceled}})
|
||||
if got != first {
|
||||
t.Fatalf("selected %v, want %v", got, first)
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
if got := selectRunError(ctx, []orderedRunError{{err: errors.New("operation")}}); got != context.Canceled {
|
||||
t.Fatal(got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user