File tree 3 files changed +31
-1
lines changed 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 11
11
],
12
12
"main" : " index.js" ,
13
13
"scripts" : {
14
+ "pretest" : " node pretest.js" ,
14
15
"test" : " mocha -R spec --timeout 10000 --require test/init.js test/*.test.js"
15
16
},
16
17
"dependencies" : {
Original file line number Diff line number Diff line change
1
+ if ( ! process . env . TEST_POSTGRESQL_USER && ! process . env . CI ) {
2
+ console . log ( 'not seeding DB with test db' ) ;
3
+ return ;
4
+ }
5
+
6
+ var fs = require ( 'fs' ) ;
7
+ var cp = require ( 'child_process' ) ;
8
+
9
+ var sql = fs . createReadStream ( require . resolve ( './test/schema.sql' ) ) ;
10
+ var stdio = [ 'pipe' , process . stdout , process . stderr ] ;
11
+ process . env . PGHOST = process . env . TEST_POSTGRESQL_HOST ||
12
+ process . env . POSTGRESQL_HOST || process . env . PGHOST || 'localhost' ;
13
+ process . env . PGPORT = process . env . TEST_POSTGRESQL_PORT ||
14
+ process . env . POSTGRESQL_PORT || process . env . PGPORT || 5432 ;
15
+ process . env . PGUSER = process . env . TEST_POSTGRESQL_USER ||
16
+ process . env . POSTGRESQL_USER || process . env . PGUSER || 'test' ;
17
+ process . env . PGPASSWORD = process . env . TEST_POSTGRESQL_PASSWORD ||
18
+ process . env . POSTGRESQL_PASSWORD || process . env . PGPASSWORD || 'test' ;
19
+
20
+ console . log ( 'seeding DB with test db...' ) ;
21
+ var psql = cp . spawn ( 'psql' , { stdio : stdio } ) ;
22
+ sql . pipe ( psql . stdin ) ;
23
+ psql . on ( 'exit' , function ( code ) {
24
+ console . log ( 'done seeding DB' ) ;
25
+ setTimeout ( function ( ) {
26
+ process . exit ( code ) ;
27
+ } , 200 ) ;
28
+ } ) ;
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ var DataSource = require('loopback-datasource-juggler').DataSource;
12
12
var db ;
13
13
14
14
before ( function ( ) {
15
- var config = require ( 'rc' ) ( 'loopback' , { dev : { postgresql : { } } } ) . dev . postgresql ;
15
+ var config = getDBConfig ( ) ;
16
+ config . database = 'strongloop' ;
16
17
db = new DataSource ( require ( '../' ) , config ) ;
17
18
} ) ;
18
19
You can’t perform that action at this time.
0 commit comments