Cleaned up console logs in tests

This commit is contained in:
Chris Troutner
2019-05-20 20:32:16 -07:00
parent 2c34e56bc3
commit 0f8fe82d50
3 changed files with 17 additions and 20 deletions
+7 -11
View File
@@ -53,17 +53,13 @@ async function createSystemUser () {
// Change the user type to admin
user.type = 'admin'
console.log(`user: ${JSON.stringify(user, null, 2)}`)
// console.log(`user: ${JSON.stringify(user, null, 2)}`)
// Save the user model.
try {
await user.save()
} catch (err) {
console.error(`Error trying to save admin user: `, err)
}
await user.save()
console.log(`admin user created: ${JSON.stringify(result.body, null, 2)}`)
console.log(`with password: ${context.password}`)
// console.log(`admin user created: ${JSON.stringify(result.body, null, 2)}`)
// console.log(`with password: ${context.password}`)
// Write out the system user information to a JSON file that external
// applications like the Task Manager and the test scripts can access.
@@ -126,7 +122,7 @@ async function loginAdmin () {
try {
// Read the exising file
existingUser = await jsonFiles.readJSON(JSON_PATH)
console.log(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
// console.log(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
// Log in as the user.
let options = {
@@ -144,9 +140,9 @@ async function loginAdmin () {
return result
} catch (err) {
console.error(`Error in admin.js/loginAdmin().`, err)
console.error(`Error in admin.js/loginAdmin().`)
console.error(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
// console.error(`existingUser: ${JSON.stringify(existingUser, null, 2)}`)
throw err
}
+6 -5
View File
@@ -102,16 +102,17 @@ async function ensureTargetUserOrAdmin (ctx, next) {
// console.log(`ctx.state.user: ${JSON.stringify(ctx.state.user, null, 2)}`)
// Ensure the calling user and the target user are the same.
if (ctx.state.user._id.toString() !== targetId.toString()) {
console.log(`Calling user and target user do not match!`)
console.log(`Calling user: ${ctx.state.user._id}`)
console.log(`Target user: ${targetId}`)
// console.log(`Calling user and target user do not match!`)
// console.log(`Calling user: ${ctx.state.user._id}`)
// console.log(`Target user: ${targetId}`)
// If they don't match, then the calling user better be an admin.
if (ctx.state.user.type !== 'admin') {
ctx.throw(401, 'not admin')
} else {
console.log(`It's ok. The user is an admin.`)
}
// else {
// console.log(`It's ok. The user is an admin.`)
// }
}
return next()
+4 -4
View File
@@ -13,7 +13,7 @@ const context = {}
describe('Users', () => {
before(async () => {
console.log(`config: ${JSON.stringify(config, null, 2)}`)
// console.log(`config: ${JSON.stringify(config, null, 2)}`)
// Create a second test user.
const userObj = {
@@ -21,7 +21,7 @@ describe('Users', () => {
password: 'pass2'
}
const testUser = await testUtils.createUser(userObj)
console.log(`testUser2: ${JSON.stringify(testUser, null, 2)}`)
// console.log(`testUser2: ${JSON.stringify(testUser, null, 2)}`)
context.user2 = testUser.user
context.token2 = testUser.token
@@ -29,7 +29,7 @@ describe('Users', () => {
// Get the JWT used to log in as the admin 'system' user.
const adminJWT = await testUtils.getAdminJWT()
console.log(`adminJWT: ${adminJWT}`)
// console.log(`adminJWT: ${adminJWT}`)
context.adminJWT = adminJWT
// const admin = await testUtils.loginAdminUser()
@@ -535,7 +535,7 @@ describe('Users', () => {
}
const result = await rp(options)
console.log(`result: ${util.inspect(result.body)}`)
// console.log(`result: ${util.inspect(result.body)}`)
assert.equal(result.body.success, true)
})