-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// exports.meta = { | ||
// api: { | ||
// version: require('../package.json').version, | ||
// } | ||
// } | ||
|
||
// exports.asInt = function (i) { | ||
// if (parseInt(i, 10)) return parseInt(i, 10) | ||
// return | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const group = require('../lib/group') | ||
// const session = require('../lib/session') | ||
const user = require('../lib/user') | ||
const userCase = require('./fixtures/user.json') | ||
const groupCase = require('./fixtures/group.json') | ||
|
||
const setup = async () => { | ||
await createTestGroup() | ||
await createTestUser() | ||
// await createTestSession() | ||
await user._mysql.disconnect() | ||
await group._mysql.disconnect() | ||
process.exit(1) | ||
} | ||
|
||
setup() | ||
|
||
async function createTestGroup() { | ||
let g = group.read({ nt_group_id: groupCase.nt_group_id }) | ||
if (g.length === 1) return | ||
|
||
await group.create(groupCase) | ||
} | ||
|
||
async function createTestUser() { | ||
let u = await user.read({ nt_user_id: userCase.nt_user_id }) | ||
if (u.length === 1) return | ||
|
||
const instance = JSON.parse(JSON.stringify(userCase)) | ||
instance.password = 'Wh@tA-Decent#P6ssw0rd' | ||
|
||
await user.create(instance) | ||
} | ||
|
||
async function createTestSession() { | ||
this.sessionId = await session.create({ | ||
nt_user_id: userCase.nt_user_id, | ||
nt_user_session: 12345, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const group = require('../lib/group') | ||
// const session = require('../lib/session') | ||
const user = require('../lib/user') | ||
const userCase = require('./fixtures/user.json') | ||
const groupCase = require('./fixtures/group.json') | ||
|
||
const teardown = async () => { | ||
// await destroyTestSession() | ||
await destroyTestUser() | ||
await destroyTestGroup() | ||
await user._mysql.disconnect() | ||
await group._mysql.disconnect() | ||
process.exit(1) | ||
} | ||
|
||
teardown() | ||
|
||
async function destroyTestGroup() { | ||
await group.destroy({ nt_group_id: groupCase.nt_group_id }) | ||
} | ||
|
||
async function destroyTestUser() { | ||
await user.destroy({ nt_user_id: userCase.nt_user_id }) | ||
} | ||
|
||
async function destroyTestSession() { | ||
// await session.destroy({ nt_user_id: ... }) | ||
} |