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 16
Expand file tree
/
Copy pathpostgres-integration-spec.js
More file actions
94 lines (77 loc) · 2.41 KB
/
Copy pathpostgres-integration-spec.js
File metadata and controls
94 lines (77 loc) · 2.41 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var bluebird = require('bluebird');
var FixtureGenerator = require('../../lib/fixture-generator');
var specs = require('./integration-specs');
var dbConfig = {
client: 'pg',
connection: {
host: process.env.DOCKER_IP || 'pg',
user: 'testdb',
password: 'password',
database: 'testdb',
port: Number(process.env.DOCKER_PORT || 5432)
}
};
describe("postgres intregation tests", function() {
specs(dbConfig);
// postgres specific specs below
describe("array data type", function() {
this.timeout(6000);
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('simple_array_table'),
knex.schema.dropTableIfExists('has_array_column')
];
bluebird.all(dropPromises).then(function() {
knex.schema.createTable('simple_array_table', function(table) {
table.increments('id').primary();
table.integer('integer_column');
}).then(function() {
knex.raw("create table has_array_column(integers integer[])").then(function() {
done();
});
});
});
});
it('should insert hard coded arrays', function(done) {
var dataConfig = {
has_array_column: {
integers: [4,5,6]
}
};
var knex = this.knex;
this.fixtureGenerator.create(dataConfig).then(function(results) {
expect(results.has_array_column[0].integers).to.eql([4,5,6]);
knex('has_array_column').then(function(result) {
expect(result[0].integers).to.eql([4,5,6]);
done();
});
});
});
it('should resolve array values', function(done) {
var dataConfig = {
simple_array_table: {
integer_column: 8
},
has_array_column: {
integers: [4,5, 'simple_array_table:0:integer_column']
}
};
var knex = this.knex;
this.fixtureGenerator.create(dataConfig).then(function(results) {
expect(results.has_array_column[0].integers).to.eql([4,5,8]);
knex('has_array_column').then(function(result) {
expect(result[0].integers).to.eql([4,5,8]);
done();
});
});
});
});
});