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

Method CreateTempFile

pkg/tools/builtin/testutils.go:54–67  ·  view source on GitHub ↗

CreateTempFile 创建临时文件

(name, content string)

Source from the content-addressed store, hash-verified

52
53// CreateTempFile 创建临时文件
54func (th *TestHelper) CreateTempFile(name, content string) string {
55 path := filepath.Join(th.TmpDir, name)
56
57 // 确保目录存在
58 if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
59 th.T.Fatalf("Failed to create dir: %v", err)
60 }
61
62 if err := os.WriteFile(path, []byte(content), 0644); err != nil {
63 th.T.Fatalf("Failed to create file: %v", err)
64 }
65
66 return path
67}
68
69// CreateTempDir 创建临时目录
70func (th *TestHelper) CreateTempDir(name string) string {

Callers 15

TestReadTool_SuccessFunction · 0.95
TestReadTool_EmptyFileFunction · 0.95
TestReadTool_LargeFileFunction · 0.95
TestEditTool_SimpleEditFunction · 0.95
TestEditTool_SameStringFunction · 0.95

Calls 1

JoinMethod · 0.45

Tested by 14

TestReadTool_SuccessFunction · 0.76
TestReadTool_EmptyFileFunction · 0.76
TestReadTool_LargeFileFunction · 0.76
TestEditTool_SimpleEditFunction · 0.76
TestEditTool_SameStringFunction · 0.76