feat(tools/basic): 内置基础工具(calculator(注入安全)/datetime/random/text/json/markdown)+ 批量注册
This commit is contained in:
1 parent
b3c61aa1ff
commit
08223c06a5
19 files changed
+2074
No files matched your search
@@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user