|
| 1 | +const path = require('node:path'); |
| 2 | +const coffee = require('coffee'); |
| 3 | +const mm = require('mm'); |
| 4 | +const fs = require('node:fs/promises'); |
| 5 | +const assert = require('assert'); |
| 6 | + |
| 7 | +describe('test/lib/cmd/dal.test.js', () => { |
| 8 | + const eggBin = require.resolve('../../../bin/egg-bin.js'); |
| 9 | + const cwd = path.join(__dirname, '../../fixtures/dal'); |
| 10 | + |
| 11 | + afterEach(mm.restore); |
| 12 | + |
| 13 | + describe('egg-bin dal gen', () => { |
| 14 | + after(async () => { |
| 15 | + await fs.rm(path.join(cwd, 'app/modules/dal/dal'), { |
| 16 | + recursive: true, |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + it('egg-bin dal gen should work', async () => { |
| 21 | + await coffee.fork(eggBin, [ 'dal', 'gen' ], { cwd }) |
| 22 | + .debug() |
| 23 | + .expect('code', 0) |
| 24 | + .end(); |
| 25 | + |
| 26 | + for (const file of [ |
| 27 | + 'app/modules/dal/dal/dao/BarDAO.ts', |
| 28 | + 'app/modules/dal/dal/dao/FooDAO.ts', |
| 29 | + 'app/modules/dal/dal/dao/base/BaseBarDAO.ts', |
| 30 | + 'app/modules/dal/dal/dao/base/BaseFooDAO.ts', |
| 31 | + 'app/modules/dal/dal/extension/BarExtension.ts', |
| 32 | + 'app/modules/dal/dal/extension/FooExtension.ts', |
| 33 | + 'app/modules/dal/dal/structure/Bar.json', |
| 34 | + 'app/modules/dal/dal/structure/Bar.sql', |
| 35 | + 'app/modules/dal/dal/structure/Foo.json', |
| 36 | + 'app/modules/dal/dal/structure/Foo.sql', |
| 37 | + ]) { |
| 38 | + assert.ok(fs.stat(path.join(cwd, file))); |
| 39 | + } |
| 40 | + }); |
| 41 | + }); |
| 42 | +}); |
0 commit comments