mirror of
https://github.com/Permissionless-Software-Foundation/bch-email-api.git
synced 2026-09-21 16:52:04 -07:00
Added integration test for getUsers
This commit is contained in:
@@ -3,10 +3,14 @@
|
||||
const util = require('util')
|
||||
util.inspect.defaultOptions = { depth: 1 }
|
||||
|
||||
async function createUser (ctx) {
|
||||
ctx.body = {}
|
||||
}
|
||||
|
||||
/*
|
||||
Create a new user by manipulating the postgres database.
|
||||
*/
|
||||
async function createUser (ctx) {
|
||||
async function getUsers (ctx) {
|
||||
try {
|
||||
// console.log(`ctx.iRedMail: ${util.inspect(ctx.iRedMail)}`)
|
||||
|
||||
@@ -14,13 +18,7 @@ async function createUser (ctx) {
|
||||
const model = await ctx.iRedMail.models.usedQuota.sync()
|
||||
|
||||
const data = await model.findAll()
|
||||
/*
|
||||
// Get all the models in the database:
|
||||
const models = await ctx.iRedMail.usedQuota.findAll()
|
||||
|
||||
console.log(`data: ${JSON.stringify(models, null, 2)}`)
|
||||
ctx.body = { models }
|
||||
*/
|
||||
ctx.body = data
|
||||
} catch (err) {
|
||||
console.log(`Error in iredmail.createUser(): `, err)
|
||||
@@ -47,5 +45,6 @@ async function createUser (ctx) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createUser
|
||||
createUser,
|
||||
getUsers
|
||||
}
|
||||
|
||||
@@ -10,5 +10,12 @@ module.exports.routes = [
|
||||
handlers: [
|
||||
iredmail.createUser
|
||||
]
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
route: '/',
|
||||
handlers: [
|
||||
iredmail.getUsers
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -50,4 +50,26 @@ describe('#iRedMail', () => {
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('#getUsers', () => {
|
||||
if (process.env.TEST_ENV === 'integration') {
|
||||
it('should get database models', async () => {
|
||||
try {
|
||||
// console.log(`Hello world!`)
|
||||
|
||||
const options = {
|
||||
method: 'GET',
|
||||
uri: `${LOCALHOST}/iredmail`,
|
||||
resolveWithFullResponse: true,
|
||||
json: true
|
||||
}
|
||||
|
||||
let result = await rp(options)
|
||||
console.log(`result: ${util.inspect(result.body)}`)
|
||||
} catch (err) {
|
||||
console.log(`Error in #createUser test: `, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user