Q4 成熟度路线图全部完成:
1. 集成测试框架 (Testcontainers + PostgreSQL):
- auth_tests: 用户 CRUD、租户隔离、用户名唯一性
- plugin_tests: 动态表创建查询、租户数据隔离
2. Playwright E2E 测试:
- 登录页面渲染和表单验证测试
- 用户管理、插件管理、多租户隔离占位测试
3. 进销存插件 (erp-plugin-inventory):
- 6 实体: 产品/仓库/库存/供应商/采购单/销售单
- 12 权限、6 页面、完整 manifest
- WASM 编译验证通过
4. 插件热更新:
- POST /api/v1/admin/plugins/{id}/upgrade
- manifest 对比 + 增量 DDL + WASM 热加载
- 失败保持旧版本继续运行
5. 文档更新: CLAUDE.md + wiki/index.md 同步 Q2-Q4 进度
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use sea_orm::Database;
|
|
use erp_server_migration::MigratorTrait;
|
|
use testcontainers_modules::postgres::Postgres;
|
|
use testcontainers::runners::AsyncRunner;
|
|
|
|
/// 测试数据库容器 — 启动真实 PostgreSQL 执行迁移后提供 DB 连接
|
|
pub struct TestDb {
|
|
pub db: sea_orm::DatabaseConnection,
|
|
_container: testcontainers::ContainerAsync<Postgres>,
|
|
}
|
|
|
|
impl TestDb {
|
|
pub async fn new() -> Self {
|
|
let postgres = Postgres::default()
|
|
.with_db_name("erp_test")
|
|
.with_user("test")
|
|
.with_password("test");
|
|
|
|
let container = postgres
|
|
.start()
|
|
.await
|
|
.expect("启动 PostgreSQL 容器失败");
|
|
|
|
let host_port = container
|
|
.get_host_port_ipv4(5432)
|
|
.await
|
|
.expect("获取容器端口失败");
|
|
|
|
let url = format!("postgres://test:test@127.0.0.1:{}/erp_test", host_port);
|
|
let db = Database::connect(&url)
|
|
.await
|
|
.expect("连接测试数据库失败");
|
|
|
|
// 运行所有迁移
|
|
erp_server_migration::Migrator::up(&db, None)
|
|
.await
|
|
.expect("执行数据库迁移失败");
|
|
|
|
Self {
|
|
db,
|
|
_container: container,
|
|
}
|
|
}
|
|
}
|