-
Notifications
You must be signed in to change notification settings - Fork 14
/
mssql-destination.spec.ts
58 lines (51 loc) · 1.56 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
48
49
50
51
52
53
54
55
56
57
58
import { Job, DynamicProcessor, MssqlDestination } from '../src';
import { IMssqlDbConnection } from '../src/types';
import * as utils from '../src/utils';
let db: any = null;
const connection: IMssqlDbConnection = {
user: 'sa',
password: 'Passw0rd*',
server: 'mssql',
database: 'tempdb',
options: {
trustServerCertificate: true,
}
};
describe.each(['tedious', 'msnodesqlv8'])('different drivers', (driverName) => {
beforeAll(async () => {
if (driverName === 'msnodesqlv8') {
connection.driver = await import('mssql/msnodesqlv8');
}
});
beforeEach(async () => {
db = await utils.getDb(connection, 'mssql');
await db.query(`DROP TABLE IF EXISTS test_sources`);
await db.query(`CREATE TABLE test_sources
(
id integer
)`);
});
afterEach(async () => {
await utils.closeDbConnection(connection);
})
it(`inserts generated data to mssql using ${driverName} driver`, async () => {
const processor = new DynamicProcessor({
generator: async function* () {
yield {
id: 1,
}
},
});
const destination = new MssqlDestination({
connection,
table: 'test_sources',
batchSize: 1,
});
const job = new Job(processor, [destination]);
await job.run();
const res = await db.query(`select * from test_sources`);
expect(res.recordset).toEqual([{
id: 1,
}]);
});
});