import { initDatabase, pool } from './server/src/db/mysql'; import { repo } from './server/src/db/repository'; async function main() { await initDatabase(); const stamp = Date.now(); const uid = (stamp % 800000000) + 100000001; const results: Array<[string, boolean, string]> = []; const check = (name: string, ok: boolean, detail = '') => results.push([name, ok, detail]); try { await pool.query( `INSERT INTO users (id, user_no, nickname, avatar, phone, gender, role, balance, order_count, status) VALUES (?, ?, 'smoke-plain-user', '', '13100001111', '保密', '普通玩家', 0, 5, '正常')`, [uid, `SMPU${stamp}`] ); const p: any = await repo.getCompanionById(uid); check('普通用户档案标记 isCompanion=false', p && p.isCompanion === false, JSON.stringify({ isCompanion: p && p.isCompanion })); check('评分不再虚构(0)', Number(p.rating) === 0, String(p && p.rating)); check('单量不再虚构(0)', Number(p.orderCount) === 0, String(p && p.orderCount)); check('价格不再虚构(0)', Number(p.price) === 0, String(p && p.price)); check('不返回虚构服务包', Array.isArray(p.services) && p.services.length === 0, JSON.stringify(p && p.services)); check('状态为休息中', p.status === '休息中', String(p && p.status)); check('审核状态为未申请', p.auditStatus === '未申请', String(p && p.auditStatus)); } finally { await pool.query('DELETE FROM companions WHERE user_id = ?', [uid]); await pool.query('DELETE FROM users WHERE id = ?', [uid]); } let allPass = true; for (const [n, ok, detail] of results) { if (!ok) allPass = false; console.log(`${ok ? 'PASS' : 'FAIL'} ${n} ${detail}`); } console.log(allPass ? '\nBATCH66 SMOKE: ALL PASS' : '\nBATCH66 SMOKE: FAILED'); await pool.end(); process.exit(allPass ? 0 : 1); } main().catch((e) => { console.error('SMOKE ERROR', e); process.exit(2); });