Merge pull request #1299 from trheyi/main

Add test for assistant creation and script execution
This commit is contained in:
Max 2025-11-13 15:24:03 +08:00 committed by GitHub
commit d385d3bf86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,11 @@
package hook_test package hook_test
import ( import (
"context"
"testing" "testing"
"github.com/yaoapp/yao/agent/assistant"
agentContext "github.com/yaoapp/yao/agent/context"
"github.com/yaoapp/yao/agent/testutils" "github.com/yaoapp/yao/agent/testutils"
) )
@ -10,4 +13,22 @@ import (
func TestCreate(t *testing.T) { func TestCreate(t *testing.T) {
testutils.Prepare(t) testutils.Prepare(t)
defer testutils.Clean(t) defer testutils.Clean(t)
agent, err := assistant.Get("tests.create")
if err != nil {
t.Fatalf("Failed to get the tests.create assistant: %s", err.Error())
}
if agent.Script == nil {
t.Fatalf("The tests.create assistant has no script")
}
ctx := &agentContext.Context{
Context: context.Background(),
ChatID: "chat-test-create-hook",
AssistantID: "tests.create",
Sid: "test-session-create-hook",
}
agent.Script.Create(ctx, []agentContext.Message{{Role: "user", Content: "Hello, how are you?"}})
} }