This repository was archived by the owner on Feb 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsqlite-integration-spec.js
75 lines (63 loc) · 2.25 KB
/
sqlite-integration-spec.js
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
var _ = require('lodash');
var bluebird = require('bluebird');
var FixtureGenerator = require('../../lib/fixture-generator');
var specs = require('./integration-specs');
var dbConfig = {
client: 'sqlite3',
connection: {
filename: './sqlite-integration-spec.db'
}
};
describe("sqlite intregation tests", function() {
specs(dbConfig);
// sqlite specific specs below
describe("using rowids", function() {
before(function() {
this.fixtureGenerator = new FixtureGenerator(dbConfig);
this.knex = this.fixtureGenerator.knex;
});
after(function(done) {
this.fixtureGenerator.destroy(done);
});
beforeEach(function(done) {
var knex = this.knex;
var dropPromises = [
knex.schema.dropTableIfExists('has_no_id_and_timestamps')
];
bluebird.all(dropPromises).then(function() {
knex.schema.createTable('has_no_id_and_timestamps', function(table) {
table.integer('integer_column');
table.timestamp('timestamp_column').defaultTo(knex.fn.now());
}).then(function() {
done();
});
});
});
it('should select the correct row', function(done) {
this.timeout(4000);
var me = this;
var firstConfig = {
has_no_id_and_timestamps: [
{ integer_column: 2, timestamp_column: null },
{ integer_column: 2, timestamp_column: null },
{ integer_column: 2, timestamp_column: null },
{ integer_column: 2, timestamp_column: null },
{ integer_column: 2, timestamp_column: null }
]
};
this.fixtureGenerator.create(firstConfig).then(function(firstResults) {
setTimeout(function() {
var dataConfig = {
has_no_id_and_timestamps: { integer_column: 2, timestamp_column: null }
};
me.fixtureGenerator.create(dataConfig).then(function(nextResults) {
// if we got the correct row, it will have a timestamp not found in the previous set
var previousTimestamps = _.map(firstResults.has_no_id_and_timestamps, 'timestamp_column');
expect(previousTimestamps).to.not.contain(nextResults.has_no_id_and_timestamps[0].timestamp_column);
done();
});
}, 2000);
});
});
});
});