Files

26 lines
607 B
Go

package basic
import (
"context"
"errors"
"testing"
)
// TestExecute_HonorsCancellation verifies every tool returns the context error
// when ctx is already canceled, without performing any work.
func TestExecute_HonorsCancellation(t *testing.T) {
t.Parallel()
ctx, cancel := context.WithCancel(context.Background())
cancel()
for _, tool := range Tools() {
tool := tool
t.Run(tool.Name(), func(t *testing.T) {
t.Parallel()
_, err := tool.Execute(ctx, map[string]any{})
if !errors.Is(err, context.Canceled) {
t.Fatalf("err = %v, want wrapping context.Canceled", err)
}
})
}
}