NewTestHelper 创建测试辅助工具
(t *testing.T)
| 24 | |
| 25 | // NewTestHelper 创建测试辅助工具 |
| 26 | func NewTestHelper(t *testing.T) *TestHelper { |
| 27 | tmpDir, err := os.MkdirTemp("", "agentsdk_test_*") |
| 28 | if err != nil { |
| 29 | t.Fatalf("Failed to create temp dir: %v", err) |
| 30 | } |
| 31 | |
| 32 | return &TestHelper{ |
| 33 | T: t, |
| 34 | TmpDir: tmpDir, |
| 35 | Context: context.Background(), |
| 36 | Cleanup: []func(){func() { _ = os.RemoveAll(tmpDir) }}, |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // AddCleanup 添加清理函数 |
| 41 | func (th *TestHelper) AddCleanup(cleanup func()) { |
no outgoing calls