diff --git a/sql/qqbot-init.sql b/sql/qqbot-init.sql index a206230..d3aafcf 100644 --- a/sql/qqbot-init.sql +++ b/sql/qqbot-init.sql @@ -533,6 +533,7 @@ VALUES (2041700000000300516, 'bangdream_cutoff_all', 'BangDream ycxall', '["ycxall","myycx","全部档线"]', '["/","!","!"]', 'bangDream', 'bangdream.cutoff.all', 'plain', 'all', '{}', '', 'BangDream ycxall 失败:{{error}}', 1, 0, 3000, '查询所有档位预测线;格式:/ycxall [活动ID] [服务器]'), (2041700000000300517, 'bangdream_cutoff_recent', 'BangDream lsycx', '["lsycx","历史档线","近期档线"]', '["/","!","!"]', 'bangDream', 'bangdream.cutoff.recent', 'plain', 'all', '{}', '', 'BangDream lsycx 失败:{{error}}', 1, 0, 3000, '查询同类型活动档线;格式:/lsycx 档位 [活动ID] [服务器]') ON DUPLICATE KEY UPDATE + `code` = VALUES(`code`), `name` = VALUES(`name`), `aliases` = VALUES(`aliases`), `prefixes` = VALUES(`prefixes`), diff --git a/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts b/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts new file mode 100644 index 0000000..ec64b74 --- /dev/null +++ b/test/qqbot/plugins/bangDream/qqbot-bangdream-command-sql.spec.ts @@ -0,0 +1,26 @@ +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { BANGDREAM_OPERATION_DEFS } from '@/qqbot/plugins/bangDream/commands/qqbot-bangdream-command.definitions'; + +describe('qqbot BangDream command init SQL', () => { + const sql = readFileSync(join(process.cwd(), 'sql/qqbot-init.sql'), 'utf8'); + + it('keeps every BangDream plugin operation available as an online command', () => { + const sqlOperationKeys = Array.from( + sql.matchAll(/'bangDream', '([^']+)'/g), + ).map((match) => match[1]); + const definedOperationKeys = BANGDREAM_OPERATION_DEFS.map( + (operation) => operation.key, + ); + + expect([...sqlOperationKeys].sort()).toEqual( + [...definedOperationKeys].sort(), + ); + expect(sqlOperationKeys).toHaveLength(15); + }); + + it('overwrites dirty online command metadata on duplicate ids', () => { + expect(sql).toContain('`code` = VALUES(`code`)'); + expect(sql).toContain('`is_deleted` = 0'); + }); +});