forked from Claviz/bellboy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mssql-destination.spec.ts
47 lines (42 loc) · 1.04 KB
/
mssql-destination.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Job, DynamicProcessor, MssqlDestination } from '../src';
import * as utils from '../src/utils';
let db: any = null;
const connection = {
user: 'sa',
password: 'Passw0rd*',
server: 'mssql',
database: 'tempdb',
};
beforeAll(async () => {
db = await utils.getDb(connection, 'mssql');
});
beforeEach(async () => {
await db.query(`DROP TABLE IF EXISTS test`);
await db.query(`CREATE TABLE test
(
id integer
)`);
});
afterAll(async () => {
await utils.closeDbConnection(connection);
})
it('inserts generated data to mssql', async () => {
const processor = new DynamicProcessor({
generator: async function* () {
yield {
id: 1,
}
},
});
const destination = new MssqlDestination({
connection,
table: 'test',
batchSize: 1,
});
const job = new Job(processor, [destination]);
await job.run();
const res = await db.query(`select * from test`);
expect(res.recordset).toEqual([{
id: 1,
}]);
});