Changeset 0.24.1 (#157)

This commit is contained in:
2026-03-07 17:11:32 +00:00
parent a63728a481
commit b6cc4df6e7
27 changed files with 2094 additions and 453 deletions

View File

@@ -3299,3 +3299,45 @@ func TestIntegration_Messages_TreePath(t *testing.T) {
t.Fatalf("last in path should be follow-up, got %q", last["content"])
}
}
// ── Channel List with Type Filter (regression: $1 reuse in SQLite) ──
func TestIntegration_ChannelListWithTypeFilter(t *testing.T) {
h := setupHarness(t)
_, token := h.createAdminUser("admin", "admin@test.com")
// Create a direct chat
w := h.request("POST", "/api/v1/channels", token, map[string]interface{}{
"title": "Test Direct Chat",
"type": "direct",
})
if w.Code != http.StatusCreated {
t.Fatalf("create channel: want 201, got %d: %s", w.Code, w.Body.String())
}
// List without type filter — should succeed
w = h.request("GET", "/api/v1/channels?page=1&per_page=100", token, nil)
if w.Code != http.StatusOK {
t.Fatalf("list channels (no filter): want 200, got %d: %s", w.Code, w.Body.String())
}
// List with single type filter
w = h.request("GET", "/api/v1/channels?page=1&per_page=100&type=direct", token, nil)
if w.Code != http.StatusOK {
t.Fatalf("list channels (type=direct): want 200, got %d: %s", w.Code, w.Body.String())
}
// List with multi-value types filter — this triggers the $1 reuse in the
// count subquery. Before the QArgs fix, this returned 500 on SQLite.
w = h.request("GET", "/api/v1/channels?page=1&per_page=100&types=direct,group", token, nil)
if w.Code != http.StatusOK {
t.Fatalf("list channels (types=direct,group): want 200, got %d: %s", w.Code, w.Body.String())
}
// Verify the response is valid
var resp map[string]interface{}
decode(w, &resp)
// The response may use "channels" or "data" depending on the handler.
// Verify the request succeeded (200) — that's the regression test.
// Channel content verification is covered by other tests.
}