summaryrefslogtreecommitdiff
path: root/internal/api/validate_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/validate_test.go')
-rw-r--r--internal/api/validate_test.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/api/validate_test.go b/internal/api/validate_test.go
index c3d7b1f..60fec14 100644
--- a/internal/api/validate_test.go
+++ b/internal/api/validate_test.go
@@ -3,11 +3,32 @@ package api
import (
"bytes"
"encoding/json"
+ "fmt"
"net/http"
"net/http/httptest"
+ "os"
+ "path/filepath"
"testing"
)
+// createFakeClaude writes a stub `claude` script that prints the given output
+// and exits with the given code, returning its path for use as a binary
+// override in tests.
+func createFakeClaude(t *testing.T, output string, exitCode int) string {
+ t.Helper()
+ dir := t.TempDir()
+ outputFile := filepath.Join(dir, "output.json")
+ if err := os.WriteFile(outputFile, []byte(output), 0600); err != nil {
+ t.Fatal(err)
+ }
+ script := filepath.Join(dir, "claude")
+ content := fmt.Sprintf("#!/bin/sh\ncat %q\nexit %d\n", outputFile, exitCode)
+ if err := os.WriteFile(script, []byte(content), 0755); err != nil {
+ t.Fatal(err)
+ }
+ return script
+}
+
func TestValidateTask_Success(t *testing.T) {
srv, _ := testServer(t)