package server import ( "bytes" "context" "encoding/json" "net/http" "net/http/httptest" "os/exec" "testing" "time" ) func TestTaskCLIHTTPIntegration(t *testing.T) { if _, e := exec.LookPath("python3"); e != nil { t.Skip("python3 not installed") } s, token, _, _ := taskFixture(t) server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { r.Host = "localhost" s.withAuthorization(s.mux).ServeHTTP(w, r) })) defer server.Close() ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() cmd := exec.CommandContext(ctx, "python3", "pages-cli/test_task_integration.py") b, _ := json.Marshal(map[string]string{"origin": server.URL, "token": token, "root": t.TempDir()}) cmd.Stdin = bytes.NewReader(b) if out, e := cmd.CombinedOutput(); e != nil { t.Fatalf("CLI task integration %v: %s", e, out) } }