-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy pathPostgresInitOptions.spec.js
79 lines (72 loc) · 2.06 KB
/
PostgresInitOptions.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
76
77
78
79
const Parse = require('parse/node').Parse;
const PostgresStorageAdapter = require('../lib/Adapters/Storage/Postgres/PostgresStorageAdapter')
.default;
const postgresURI =
process.env.PARSE_SERVER_TEST_DATABASE_URI ||
'postgres://localhost:5432/parse_server_postgres_adapter_test_database';
//public schema
const databaseOptions1 = {
initOptions: {
schema: 'public',
},
};
//not exists schema
const databaseOptions2 = {
initOptions: {
schema: 'not_exists_schema',
},
};
const GameScore = Parse.Object.extend({
className: 'GameScore',
});
describe_only_db('postgres')('Postgres database init options', () => {
it('should create server with public schema databaseOptions', async () => {
const adapter = new PostgresStorageAdapter({
uri: postgresURI,
collectionPrefix: 'test_',
databaseOptions: databaseOptions1,
});
await reconfigureServer({
databaseAdapter: adapter,
});
const score = new GameScore({
score: 1337,
playerName: 'Sean Plott',
cheatMode: false,
});
await score.save();
});
it('should create server using postgresql uri with public schema databaseOptions', async () => {
const postgresURI2 = new URL(postgresURI);
postgresURI2.protocol = 'postgresql:';
const adapter = new PostgresStorageAdapter({
uri: postgresURI2.toString(),
collectionPrefix: 'test_',
databaseOptions: databaseOptions1,
});
await reconfigureServer({
databaseAdapter: adapter,
});
const score = new GameScore({
score: 1337,
playerName: 'Sean Plott',
cheatMode: false,
});
await score.save();
});
it('should fail to create server if schema databaseOptions does not exist', async () => {
const adapter = new PostgresStorageAdapter({
uri: postgresURI,
collectionPrefix: 'test_',
databaseOptions: databaseOptions2,
});
try {
await reconfigureServer({
databaseAdapter: adapter,
});
fail("Should have thrown error");
} catch(error) {
expect(error).toBeDefined();
}
});
});