mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add testing setup in backend
This commit is contained in:
1 parent
cb376caff0
commit
1f77328362
15 files changed
+92
-100
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { User } from '@linux-odyssey/models'
|
||||
import config from '../config.js'
|
||||
import { createUser } from '../models/userManager.js'
|
||||
|
||||
export default async function setupTest() {
|
||||
console.log('Setting up test account')
|
||||
if (!(config.testing.username && config.testing.password)) {
|
||||
throw new Error(
|
||||
'No testing account found! Please set TESTING_USERNAME and TESTING_PASSWORD in .env'
|
||||
)
|
||||
}
|
||||
const { username, password } = config.testing
|
||||
const email = `${username}@example.com`
|
||||
|
||||
if (await User.exists({ username })) {
|
||||
console.log('Testing account already exists')
|
||||
return
|
||||
}
|
||||
|
||||
await createUser(username, email, password)
|
||||
console.log('Created testing account')
|
||||
}
|
||||
Reference in new issue
Block a user