| @@ -694,7 +694,7 @@ func TestRemoteCloudModeDoesNotCreateLocalDB(t *testing.T) { · 693 unmodified lines |
| 694 | t.Setenv("HOME", dir) | 694 | t.Setenv("HOME", dir) |
| 695 | t.Setenv("CRAWL_REMOTE_TOKEN", "test-token") | 695 | t.Setenv("CRAWL_REMOTE_TOKEN", "test-token") |
| 696 | | 696 | |
| 697 | var sawQuery bool | 697 | var queryArgSets [][]string |
| 698 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | 698 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 699 | if got := r.Header.Get("authorization"); got != "Bearer test-token" { | 699 | if got := r.Header.Get("authorization"); got != "Bearer test-token" { |
| 700 | http.Error(w, "missing bearer", http.StatusUnauthorized) | 700 | http.Error(w, "missing bearer", http.StatusUnauthorized) |
| @@ -723,7 +723,12 @@ func TestRemoteCloudModeDoesNotCreateLocalDB(t *testing.T) { · 22 unmodified lines |
| 723 | http.Error(w, "unexpected query", http.StatusBadRequest) | 723 | http.Error(w, "unexpected query", http.StatusBadRequest) |
| 724 | return | 724 | return |
| 725 | } | 725 | } |
| 726 | sawQuery = true | 726 | argNames := make([]string, 0, len(req.Args)) |
| | 727 | for name := range req.Args { |
| | 728 | argNames = append(argNames, name) |
| | 729 | } |
| | 730 | sort.Strings(argNames) |
| | 731 | queryArgSets = append(queryArgSets, argNames) |
| 727 | _ = json.NewEncoder(w).Encode(crawlremote.QueryResult{ | 732 | _ = json.NewEncoder(w).Encode(crawlremote.QueryResult{ |
| 728 | Values: []map[string]any{{ | 733 | Values: []map[string]any{{ |
| 729 | "thread_id": 10, | 734 | "thread_id": 10, |
| @@ -790,8 +795,10 @@ func TestRemoteCloudModeDoesNotCreateLocalDB(t *testing.T) { · 60 unmodified lines |
| 790 | if err := searchApp.Run(ctx, []string{"--config", configPath, "--json", "search", "openclaw/openclaw", "--query", "remote"}); err != nil { | 795 | if err := searchApp.Run(ctx, []string{"--config", configPath, "--json", "search", "openclaw/openclaw", "--query", "remote"}); err != nil { |
| 791 | t.Fatalf("remote search: %v", err) | 796 | t.Fatalf("remote search: %v", err) |
| 792 | } | 797 | } |
| 793 | if !sawQuery || !strings.Contains(searchOut.String(), `"remote search"`) { | 798 | if len(queryArgSets) != 1 || |
| 794 | t.Fatalf("remote search did not use worker query: saw=%v out=%s", sawQuery, searchOut.String()) | 799 | !slices.Equal(queryArgSets[0], []string{"limit", "mode", "owner", "query", "repo"}) || |
| | 800 | !strings.Contains(searchOut.String(), `"remote search"`) { |
| | 801 | t.Fatalf("remote search query args=%v out=%s", queryArgSets, searchOut.String()) |
| 795 | } | 802 | } |
| 796 | ghSearchApp := New() | 803 | ghSearchApp := New() |
| 797 | var ghSearchOut bytes.Buffer | 804 | var ghSearchOut bytes.Buffer |
| @@ -802,6 +809,10 @@ func TestRemoteCloudModeDoesNotCreateLocalDB(t *testing.T) { · 4 unmodified lines |
| 802 | if !strings.Contains(ghSearchOut.String(), `"number": 42`) || !strings.Contains(ghSearchOut.String(), `"url": "https://github.com/openclaw/openclaw/issues/42"`) { | 809 | if !strings.Contains(ghSearchOut.String(), `"number": 42`) || !strings.Contains(ghSearchOut.String(), `"url": "https://github.com/openclaw/openclaw/issues/42"`) { |
| 803 | t.Fatalf("remote gh search output = %s", ghSearchOut.String()) | 810 | t.Fatalf("remote gh search output = %s", ghSearchOut.String()) |
| 804 | } | 811 | } |
| | 812 | if len(queryArgSets) != 2 || |
| | 813 | !slices.Equal(queryArgSets[1], []string{"kind", "limit", "owner", "query", "repo", "state"}) { |
| | 814 | t.Fatalf("remote gh search query args=%v", queryArgSets) |
| | 815 | } |
| 805 | doctorApp := New() | 816 | doctorApp := New() |
| 806 | var doctorOut bytes.Buffer | 817 | var doctorOut bytes.Buffer |
| 807 | doctorApp.Stdout = &doctorOut | 818 | doctorApp.Stdout = &doctorOut |
| @@ -829,8 +840,15 @@ func TestRemoteCloudModeDoesNotCreateLocalDB(t *testing.T) { · 21 unmodified lines |
| 829 | func testSnapshotPublishContract() crawlremote.Contract { | 840 | func testSnapshotPublishContract() crawlremote.Contract { |
| 830 | contract := crawlremote.BaseContract() | 841 | contract := crawlremote.BaseContract() |
| 831 | contract.Apps = []crawlremote.AppSpec{{ | 842 | contract.Apps = []crawlremote.AppSpec{{ |
| 832 | App: "gitcrawl", | 843 | App: "gitcrawl", |
| 833 | Queries: gitcrawlCloudReaderQuerySpecs(), | 844 | Queries: []crawlremote.QuerySpec{ |
| | 845 | {Name: "gitcrawl.threads.search", Args: []string{"owner", "repo", "query", "kind", "state", "mode", "limit"}}, |
| | 846 | {Name: "gitcrawl.clusters.related", Args: []string{"owner", "repo", "number"}}, |
| | 847 | {Name: "gitcrawl.clusters.list", Args: []string{"owner", "repo", "status", "min_size"}}, |
| | 848 | {Name: "gitcrawl.clusters.members", Args: []string{"owner", "repo", "cluster_id"}}, |
| | 849 | {Name: "gitcrawl.pull_requests.review_context", Args: []string{"owner", "repo", "number"}}, |
| | 850 | {Name: "gitcrawl.coverage", Args: []string{"dataset"}}, |
| | 851 | }, |
| 834 | IngestTables: []crawlremote.IngestTableSpec{ | 852 | IngestTables: []crawlremote.IngestTableSpec{ |
| 835 | {Name: "repositories", Columns: gitcrawlRepositoryColumns}, | 853 | {Name: "repositories", Columns: gitcrawlRepositoryColumns}, |
| 836 | {Name: "threads", Columns: gitcrawlThreadColumns}, | 854 | {Name: "threads", Columns: gitcrawlThreadColumns}, |