Files
Agent-Native/exec/backend_test.go
weichenandCursor fedf671a48
ci / vet-and-test (push) Successful in 5s
ci / docker-checkout-hostgateway (push) Successful in 3s
Import the current agent-native module as a fresh history.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-29 12:29:04 +00:00

41 lines
788 B
Go

package exec_test
import (
"context"
"os"
"path/filepath"
"testing"
"time"
"agent-native/exec"
)
func TestStubBackendExecution(t *testing.T) {
tmpDir := t.TempDir()
backend := &exec.StubBackend{}
if backend.Name() != "stub" {
t.Errorf("expected stub backend, got %s", backend.Name())
}
req := exec.Request{
WorkDir: tmpDir,
Prompt: "请编写用户初始需求收集表",
Targets: []string{"output.md"},
Timeout: 5 * time.Second,
}
res, err := backend.Execute(context.Background(), req)
if err != nil {
t.Fatalf("stub execute failed: %v", err)
}
if !res.Success {
t.Fatalf("expected success")
}
outputPath := filepath.Join(tmpDir, "output.md")
if _, err := os.Stat(outputPath); err != nil {
t.Fatalf("expected output.md to exist: %v", err)
}
}