mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 17:12:03 -07:00
Got first test working with controlled start
This commit is contained in:
+39
-1
@@ -1,4 +1,7 @@
|
||||
const mongoose = require('mongoose')
|
||||
const rp = require('request-promise')
|
||||
|
||||
const LOCALHOST = 'http://localhost:5000'
|
||||
|
||||
function cleanDb () {
|
||||
for (const collection in mongoose.connection.collections) {
|
||||
@@ -23,7 +26,42 @@ function authUser (agent, callback) {
|
||||
})
|
||||
}
|
||||
|
||||
// This function is used to create new users.
|
||||
// userObj = {
|
||||
// username,
|
||||
// password
|
||||
// }
|
||||
async function createUser (userObj) {
|
||||
try {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
uri: `${LOCALHOST}/users`,
|
||||
resolveWithFullResponse: true,
|
||||
json: true,
|
||||
body: {
|
||||
user: {
|
||||
username: userObj.username,
|
||||
password: userObj.password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let result = await rp(options)
|
||||
|
||||
const retObj = {
|
||||
user: result.body.user,
|
||||
token: result.body.token
|
||||
}
|
||||
|
||||
return retObj
|
||||
} catch (err) {
|
||||
console.log('Error in utils.js/createUser(): ' + JSON.stringify(err, null, 2))
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
cleanDb,
|
||||
authUser
|
||||
authUser,
|
||||
createUser
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user