All files / db rethinkdbdash-instance.js

100% Statements 4/4
69.23% Branches 9/13
100% Functions 2/2
100% Lines 4/4
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    1x 1x   1x         20x                                    
// This file is only used for testing, will work with cirlceci in future
 
const host = process.env.RETHINKDB_HOST || '127.0.0.1';
const port = process.env.RETHINKDB_PORT || 28015;
 
const r = require('rethinkdbdash')({
  db: "test",
  servers: [ { host, port } ]
});
 
Iasync function freshUserTable() {
  try {
    await r.tableDrop('users').run();
  } catch (err) {
    if (err.msg !== 'Table `test.users` does not exist.')
      throw err;
  }
 
  try {
    await r.tableCreate('users').run();
  } catch (err) {
    if (err.msg !== 'Table `test.users` already exists.')
      throw err;
  }
}
 
export { freshUserTable };
export default r;