fix(tests): resolve workspace compilation + CJK search failures
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- saas test harness: align WorkerDispatcher::new and AppState::new
  signatures with SpawnLimiter addition and init_db(&DatabaseConfig)
- growth sqlite: add CJK fallback (LIKE-based) when FTS5 unicode61
  tokenizer fails on Chinese queries (unicode61 doesn't index CJK)
This commit is contained in:
iven
2026-04-04 00:34:34 +08:00
parent 5db2907420
commit 8faefd6a61
2 changed files with 64 additions and 21 deletions

View File

@@ -24,9 +24,9 @@ use sqlx::PgPool;
use std::sync::atomic::{AtomicBool, Ordering};
use tokio_util::sync::CancellationToken;
use tower::ServiceExt;
use zclaw_saas::config::SaaSConfig;
use zclaw_saas::config::{DatabaseConfig, SaaSConfig};
use zclaw_saas::db::init_db;
use zclaw_saas::state::AppState;
use zclaw_saas::state::{AppState, SpawnLimiter};
use zclaw_saas::workers::WorkerDispatcher;
pub const MAX_BODY: usize = 2 * 1024 * 1024;
@@ -123,7 +123,11 @@ pub async fn build_test_app() -> (Router, PgPool) {
drop(truncate_pool);
// init_db: schema (IF NOT EXISTS, fast) + seed data
let pool = init_db(&db_url).await.expect("init_db failed");
let db_config = DatabaseConfig {
url: db_url,
..DatabaseConfig::default()
};
let pool = init_db(&db_config).await.expect("init_db failed");
let mut config = SaaSConfig::default();
config.auth.jwt_expiration_hours = 24;
@@ -131,9 +135,10 @@ pub async fn build_test_app() -> (Router, PgPool) {
config.rate_limit.requests_per_minute = 10_000;
config.rate_limit.burst = 1_000;
let dispatcher = WorkerDispatcher::new(pool.clone());
let worker_limiter = SpawnLimiter::new("test-worker", 20);
let dispatcher = WorkerDispatcher::new(pool.clone(), worker_limiter.clone());
let shutdown_token = CancellationToken::new();
let state = AppState::new(pool.clone(), config, dispatcher, shutdown_token).expect("AppState::new failed");
let state = AppState::new(pool.clone(), config, dispatcher, shutdown_token, worker_limiter).expect("AppState::new failed");
let router = build_router(state);
(router, pool)
}