connection-manager.test.js
2.08 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
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require('../../support'),
dialect = Support.getTestDialect(),
DataTypes = require('../../../../lib/data-types'),
_ = require('lodash');
if (dialect.match(/^postgres/)) {
describe('[POSTGRES] Sequelize', () => {
function checkTimezoneParsing(baseOptions) {
const options = _.extend({}, baseOptions, { timezone: 'Asia/Kolkata', timestamps: true });
const sequelize = Support.createSequelizeInstance(options);
const tzTable = sequelize.define('tz_table', { foo: DataTypes.STRING });
return tzTable.sync({force: true}).then(() => {
return tzTable.create({foo: 'test'}).then(row => {
expect(row).to.be.not.null;
});
});
}
it('should correctly parse the moment based timezone', function() {
return checkTimezoneParsing(this.sequelize.options);
});
it('should correctly parse the moment based timezone while fetching hstore oids', function() {
// reset oids so we need to refetch them
DataTypes.HSTORE.types.postgres.oids = [];
DataTypes.HSTORE.types.postgres.array_oids = [];
return checkTimezoneParsing(this.sequelize.options);
});
});
describe('Dynamic OIDs', () => {
const dynamicTypesToCheck = [
DataTypes.GEOMETRY,
DataTypes.HSTORE,
DataTypes.GEOGRAPHY,
DataTypes.ENUM,
DataTypes.CITEXT
];
it('should fetch dynamic oids from the database', () => {
dynamicTypesToCheck.forEach(type => {
type.types.postgres.oids = [];
type.types.postgres.array_oids = [];
});
// Model is needed to test the ENUM dynamic OID
const User = Support.sequelize.define('User', {
perms: DataTypes.ENUM([
'foo', 'bar'
])
});
return User.sync({force: true}).then(() => {
dynamicTypesToCheck.forEach(type => {
expect(type.types.postgres.oids, `DataType.${type.key}`).to.not.be.empty;
expect(type.types.postgres.array_oids, `DataType.${type.key}`).to.not.be.empty;
});
});
});
});
}