build: 内置 norma 模块,构建不再依赖上游仓库
把 github.com/Autumn-27/norma v0.4.3(commit 320ae32)的源码复制到 third_party/norma,并用 go.mod 的 replace 指向本地副本。上游删除仓库或 改写 tag 都不再影响本仓库构建。 - 已验证 GOPROXY=off 下可完整编译并打出发行包 - go.sum 中该模块的两条校验记录随之删除(本地 replace 不需要哈希) - 升级方法与授权注意事项见 third_party/README.md
This commit is contained in:
1 parent
a819fa3230
commit
f782b612ec
213 files changed
+37401
-2
No files matched your search
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAskUserQuestion(t *testing.T) {
|
||||
var asked []Question
|
||||
ask := func(_ context.Context, q Question) Answer {
|
||||
asked = append(asked, q)
|
||||
// Pick the first option's label.
|
||||
return Answer{Selected: []string{q.Options[0].Label}}
|
||||
}
|
||||
tl := NewAskUserQuestion(ask)
|
||||
|
||||
input := `{"questions":[{"header":"DB","question":"Which database?","options":[{"label":"Postgres","description":"relational"},{"label":"SQLite","description":"embedded"}]}]}`
|
||||
if err := ValidateInput(tl.InputSchema(), []byte(input)); err != nil {
|
||||
t.Fatalf("schema: %v", err)
|
||||
}
|
||||
res, err := tl.Call(context.Background(), []byte(input), &ToolContext{})
|
||||
if err != nil {
|
||||
t.Fatalf("call: %v", err)
|
||||
}
|
||||
if len(asked) != 1 || asked[0].Header != "DB" || len(asked[0].Options) != 2 {
|
||||
t.Fatalf("question not passed through: %+v", asked)
|
||||
}
|
||||
if !strings.Contains(res.Flatten(), "Which database?") || !strings.Contains(res.Flatten(), "Postgres") {
|
||||
t.Fatalf("answer not returned: %q", res.Flatten())
|
||||
}
|
||||
}
|
||||
|
||||
func TestAskUserQuestionNoHandler(t *testing.T) {
|
||||
tl := NewAskUserQuestion(nil)
|
||||
res, _ := tl.Call(context.Background(), []byte(`{"questions":[{"question":"x","options":[{"label":"a"}]}]}`), &ToolContext{})
|
||||
if !res.IsError {
|
||||
t.Fatal("expected error when no handler configured")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user