1
1
const Parse = require ( 'parse/node' ) . Parse ;
2
2
const PostgresStorageAdapter = require ( '../src/Adapters/Storage/Postgres/PostgresStorageAdapter' ) ;
3
3
const postgresURI = 'postgres://localhost:5432/parse_server_postgres_adapter_test_database' ;
4
-
4
+ const Config = require ( '../src/Config' ) ;
5
5
//public schema
6
6
const databaseOptions1 = {
7
7
initOptions : {
@@ -28,33 +28,40 @@ const GameScore = Parse.Object.extend({
28
28
className : "GameScore"
29
29
} ) ;
30
30
31
- describe ( 'Postgres database init options' , ( ) => {
31
+ describe_only_db ( 'postgres' ) ( 'Postgres database init options' , ( ) => {
32
32
it ( 'should create server with public schema databaseOptions' , ( done ) => {
33
+ const config = new Config ( 'test' ) ;
34
+ // Close the current DB before continueing
35
+ config . database . adapter . _pgp . end ( ) ;
33
36
reconfigureServer ( {
34
37
databaseAdapter : new PostgresStorageAdapter ( {
35
38
uri : postgresURI , collectionPrefix : 'test_' ,
36
39
databaseOptions : databaseOptions1
37
40
} )
38
- } ) . then ( done , fail ) ;
41
+ } ) . then ( done , done . fail ) ;
39
42
} ) ;
40
43
41
44
it ( "save new GameScore in public schema" , function ( done ) {
42
45
var score = new GameScore ( { "score" : 1337 , "playerName" : "Sean Plott" , "cheatMode" : false } ) ;
43
- score . save ( ) . then ( done , fail ) ;
46
+ score . save ( ) . then ( done , done . fail ) ;
44
47
} ) ;
45
48
46
49
it ( 'should fail to create server if schema databaseOptions does not exist' , ( done ) => {
50
+ const config = new Config ( 'test' ) ;
51
+ // Close the current DB before continueing
52
+ config . database . adapter . _pgp . end ( ) ;
47
53
reconfigureServer ( {
48
54
databaseAdapter : new PostgresStorageAdapter ( {
49
55
uri : postgresURI , collectionPrefix : 'test_' ,
50
56
databaseOptions : databaseOptions2
51
57
} )
52
58
} ) . then ( ( ) => {
59
+ done . fail ( 'Should not succeed' ) ;
60
+ } , error => {
61
+ // INVALID_SCHEMA error 3F000
62
+ // https://www.postgresql.org/docs/9.5/static/errcodes-appendix.html
63
+ expect ( error . code ) . toEqual ( '3F000' ) ;
53
64
done ( ) ;
54
- } )
55
- . catch ( error => {
56
- expect ( error . code ) . toEqual ( '42P01' ) ;
57
- done ( ) ;
58
- } ) ;
65
+ } ) ;
59
66
} ) ;
60
67
} ) ;
0 commit comments