fix(hyperguild): brain Query uses POST /query with JSON body

The brain HTTP REST /query endpoint accepts POST with JSON
{query, limit}, not GET with URL query string. Surfaced by
Task 7 smoke testing — GET returned 405 Method Not Allowed.

The response shape ({results:[...]}) is unchanged; only the
request side flips to POST + JSON body. brainClient.Write was
already using POST + JSON body and is unaffected.

Tests updated to assert POST + JSON body on the Query path.
This commit is contained in:
2026-05-03 21:59:17 +02:00
parent eab8775f5f
commit 317ec20392
3 changed files with 33 additions and 14 deletions
+9 -3
View File
@@ -49,9 +49,15 @@ func TestRunBrainQuery_JSON(t *testing.T) {
}
func TestRunBrainQuery_Limit(t *testing.T) {
gotLimit := ""
gotLimit := -1
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotLimit = r.URL.Query().Get("limit")
body, _ := io.ReadAll(r.Body)
var p struct {
Query string `json:"query"`
Limit int `json:"limit"`
}
_ = json.Unmarshal(body, &p)
gotLimit = p.Limit
_, _ = w.Write([]byte(`{"results":[]}`))
}))
defer srv.Close()
@@ -60,7 +66,7 @@ func TestRunBrainQuery_Limit(t *testing.T) {
var out, errBuf bytes.Buffer
err := runBrain(context.Background(), []string{"query", "--limit", "12", "topic"}, strings.NewReader(""), &out, &errBuf)
require.NoError(t, err)
assert.Equal(t, "12", gotLimit)
assert.Equal(t, 12, gotLimit)
}
func TestRunBrainQuery_MissingTopic(t *testing.T) {