generated from azures04/Base-REST-API
Fix SQL syntax and add user registration test
Corrected a SQL syntax error in the databaseGlobals.js by removing an extraneous comma. Added a test script (test.js) to initialize the database and test user registration functionality.
This commit is contained in:
parent
f8c1340b41
commit
3346dae465
@ -68,7 +68,7 @@ function initializeDatabase() {
|
|||||||
|
|
||||||
FOREIGN KEY(productId)
|
FOREIGN KEY(productId)
|
||||||
REFERENCES products(id)
|
REFERENCES products(id)
|
||||||
ON DELETE CASCADE,
|
ON DELETE CASCADE
|
||||||
)
|
)
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
19
test.js
19
test.js
@ -0,0 +1,19 @@
|
|||||||
|
const globals = require("./modules/databaseGlobals")
|
||||||
|
const userService = require("./services/userService")
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
globals.initializeDatabase()
|
||||||
|
try {
|
||||||
|
const result = await userService.register({
|
||||||
|
firstName: "User",
|
||||||
|
lastName: "Root",
|
||||||
|
username: "admin",
|
||||||
|
password: "changme"
|
||||||
|
})
|
||||||
|
console.log(result)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user