This repository was archived by the owner on Aug 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 816
Expand file tree
/
Copy pathtest.js
More file actions
77 lines (68 loc) · 1.99 KB
/
test.js
File metadata and controls
77 lines (68 loc) · 1.99 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import assert from 'assert';
import testUtils from '../test-utils.js';
import sqlserver from './index.js';
const masterConnection = {
name: 'test sqlserver',
driver: 'sqlserver',
host: 'localhost',
database: 'master',
username: 'sa',
password: 'SuperP4ssw0rd!',
};
const connection = {
name: 'test sqlserver',
driver: 'sqlserver',
host: 'localhost',
database: 'test',
username: 'sa',
password: 'SuperP4ssw0rd!',
maxRows: 2,
};
const createDb = 'CREATE DATABASE test;';
const createTable = 'CREATE TABLE test (id int);';
const inserts = 'INSERT INTO test (id) VALUES (1), (2), (3);';
describe('drivers/sqlserver', function () {
before(function () {
this.timeout(10000);
return sqlserver
.runQuery(createDb, masterConnection)
.then(() => sqlserver.runQuery(createTable, connection))
.then(() => sqlserver.runQuery(inserts, connection));
});
it('tests connection', function () {
return sqlserver.testConnection(connection);
});
it('handles port as string', function () {
return sqlserver.testConnection({
name: 'test sqlserver',
driver: 'sqlserver',
host: 'localhost',
database: 'test',
username: 'sa',
password: 'SuperP4ssw0rd!',
port: '1433',
maxRows: 2,
});
});
it('getSchema()', function () {
return sqlserver.getSchema(connection).then((schemaInfo) => {
testUtils.hasColumnDataType(schemaInfo, 'dbo', 'test', 'id', 'int');
});
});
it('runQuery under limit', function () {
return sqlserver
.runQuery('SELECT * FROM test WHERE id = 1;', connection)
.then((results) => {
assert(!results.incomplete, 'not incomplete');
assert.equal(results.rows.length, 1, 'row length');
});
});
it('runQuery over limit', function () {
return sqlserver
.runQuery('SELECT * FROM test;', connection)
.then((results) => {
assert(results.incomplete, 'incomplete');
assert.equal(results.rows.length, 2, 'row length');
});
});
});