rethinkdb-fixtures
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -57,4 +57,6 @@ 'use strict'; | ||
this.close(); | ||
resolve(pack); | ||
return this.close().then( () => { | ||
return resolve(pack); | ||
}); | ||
},reject); | ||
@@ -61,0 +63,0 @@ }); |
{ | ||
"name": "rethinkdb-fixtures", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Easily load fixtures into Rethinkdb. Useful for testing.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,4 @@ 'use strict'; | ||
host: process.env.RETHINKDB_INSTANCE_PORT_8080_TCP_ADDR, | ||
db: process.env.RETHINKDB || 'test' | ||
db: process.env.RETHINKDB || 'test', | ||
user: 'test' | ||
}; | ||
@@ -16,0 +17,0 @@ |
'use strict'; | ||
const R = require('rethinkdb'); | ||
const Delete = require('../index').Delete; | ||
const Insert = require('../index').Insert; | ||
@@ -10,3 +8,2 @@ const Lab = require('lab'); | ||
const expect = Code.expect; | ||
let conn; | ||
const lab = exports.lab = Lab.script(); | ||
@@ -17,3 +14,4 @@ | ||
db: process.env.RETHINKDB || 'test', | ||
verbose: 1, | ||
user: 'test', | ||
verbose: true, | ||
clear: true | ||
@@ -43,56 +41,35 @@ }; | ||
lab.before( (done) => { | ||
lab.test('it clears table before inserting', (done) => { | ||
// We need to peek into db to make this test | ||
R.connect({ db: options.db, host: options.host }).then( (_conn) => { | ||
Insert(options, fixture) | ||
.then( (created) => { | ||
conn = _conn; | ||
done(); | ||
}, done); | ||
}); | ||
return created; | ||
}) | ||
.then( () => { | ||
lab.before( (done) => { | ||
return Insert(options, fixture); | ||
}) | ||
.then( () => { | ||
Insert(options,fixture).then( (result) => { | ||
return R.connect(options); | ||
}) | ||
.then( (conn) => { | ||
done(); | ||
}, done); | ||
}); | ||
return Promise.all([R.table('items').run(conn), conn]); | ||
}) | ||
.then( (promises) => { | ||
lab.after( (done) => { | ||
const [cursor, conn] = promises; | ||
return Promise.all([cursor.toArray(), conn]); | ||
}) | ||
.then( (promises) => { | ||
Delete(options, ['items', 'weirdos']).then( (result) => { | ||
const [items,conn] = promises; | ||
expect(items.length).to.equal(2); | ||
conn.close(); | ||
done(); | ||
}, done); | ||
}); | ||
lab.after( (done) => { | ||
conn.close(); | ||
done(); | ||
}); | ||
lab.test('it clears table before inserting', (done) => { | ||
fixture.items.push({ | ||
name: 'Third item' | ||
}); | ||
Insert(options, fixture) | ||
.then( (created) => { | ||
return R.table('items').count().run(conn); | ||
}).then( (count) => { | ||
// The two items from 'before' was called should have been deleted, | ||
// and three items from this run should have been inserted. | ||
expect(count).to.be.equal(3); | ||
done(); | ||
}) | ||
.catch( (err) => { | ||
done(err); | ||
}); | ||
.catch(done); | ||
}); | ||
}); |
@@ -14,2 +14,3 @@ 'use strict'; | ||
db: process.env.RETHINKDB || 'test', | ||
user: 'test', | ||
verbose: 1 | ||
@@ -16,0 +17,0 @@ }; |
@@ -13,3 +13,4 @@ 'use strict'; | ||
host: process.env.RETHINKDB_INSTANCE_PORT_8080_TCP_ADDR, | ||
db: process.env.RETHINKDB || 'test' | ||
db: process.env.RETHINKDB || 'test', | ||
user: 'test' | ||
}; | ||
@@ -16,0 +17,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21664
710