支持 Jenkins 灰度发布与独立运行数据

This commit is contained in:
2026-10-29 16:25:09 +08:00
parent ab5b3580c1
commit 27151b3ee5
30 changed files with 1284 additions and 14 deletions
+19
View File
@@ -42,6 +42,25 @@ class StorageTests(unittest.TestCase):
self.assertEqual(connection.execute('SELECT role, content FROM messages').fetchone(), ('user', '旧会话'))
connection.close()
def test_business_tables_start_empty_and_reinitialization_preserves_records(self):
connection = db.connect()
for table in ('agents', 'orders', 'tickets'):
self.assertEqual(connection.execute(f'SELECT COUNT(*) FROM {table}').fetchone()[0], 0)
connection.executescript(
"INSERT INTO agents VALUES('fixture-agent', 'fixture-password', 'Fixture Agent');"
"INSERT INTO orders(phone, track_no, status, created) VALUES('123', 'fixture-order', 'active', 'now');"
"INSERT INTO tickets(content, phone, ctime, status) VALUES('fixture-ticket', '123', 'now', 'pending');"
)
connection.commit()
connection.close()
db.init_db()
connection = db.connect()
self.assertEqual(connection.execute('SELECT username, password, name FROM agents').fetchall(),
[('fixture-agent', 'fixture-password', 'Fixture Agent')])
self.assertEqual(connection.execute('SELECT track_no FROM orders').fetchall(), [('fixture-order',)])
self.assertEqual(connection.execute('SELECT content FROM tickets').fetchall(), [('fixture-ticket',)])
connection.close()
def test_user_retry_is_idempotent_and_card_context_is_readable(self):
connection = db.connect()
connection.execute('INSERT INTO chat_history(title, ctime, utime) VALUES(?,?,?)', ('新对话', 'now', 'now'))