MCPcopy Create free account
hub / github.com/astercloud/aster / TestCreateFile

Method TestCreateFile

examples/openrouter/agent_test.go:110–124  ·  view source on GitHub ↗

============================================================================= 测试用例 =============================================================================

()

Source from the content-addressed store, hash-verified

108// =============================================================================
109
110func (s *AgentIntegrationSuite) TestCreateFile() {
111 result, err := s.ag.Chat(s.ctx, "使用 Write 工具在当前目录创建文件 test.txt,文件内容为: Hello World")
112
113 s.Require().NoError(err, "Chat 调用失败")
114 s.Require().NotNil(result, "结果不应为空")
115 s.Equal("ok", result.Status, "状态应为 ok")
116
117 // 等待文件操作完成
118 time.Sleep(300 * time.Millisecond)
119
120 // 验证文件创建
121 data, err := os.ReadFile(s.workspace + "/test.txt")
122 s.Require().NoError(err, "文件应该已创建")
123 s.Equal("Hello World", strings.TrimSpace(string(data)), "文件内容不匹配")
124}
125
126func (s *AgentIntegrationSuite) TestReadFile() {
127 // 先创建测试文件

Callers

nothing calls this directly

Calls 2

ChatMethod · 0.45
ReadFileMethod · 0.45

Tested by

no test coverage detected