feat: add records deletion before seeding
This commit is contained in:
@@ -47,12 +47,31 @@ async function prepareTests() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function clearDatabase() {
|
||||||
|
await dataSource.query(`
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
r RECORD;
|
||||||
|
BEGIN
|
||||||
|
FOR r IN (
|
||||||
|
SELECT tablename
|
||||||
|
FROM pg_tables
|
||||||
|
WHERE schemaname = 'public'
|
||||||
|
)
|
||||||
|
LOOP
|
||||||
|
EXECUTE 'TRUNCATE TABLE "' || r.tablename || '" RESTART IDENTITY CASCADE';
|
||||||
|
END LOOP;
|
||||||
|
END $$;
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
async function seed() {
|
async function seed() {
|
||||||
try {
|
try {
|
||||||
await dataSource.initialize();
|
await dataSource.initialize();
|
||||||
|
|
||||||
console.log('Database connection initialized.');
|
console.log('Database connection initialized.');
|
||||||
|
|
||||||
|
await clearDatabase();
|
||||||
await seedSuperuser();
|
await seedSuperuser();
|
||||||
await prepareTests();
|
await prepareTests();
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ POST {{baseUrl}}/auth/verify-otp
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"phone": "09121212123",
|
"phone": "09333026363",
|
||||||
"otp": "26989"
|
"otp": "55333"
|
||||||
}
|
}
|
||||||
|
|
||||||
{{
|
{{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
GET {{baseUrl}}/submissions/6183e332-d28d-45ba-90a7-942f9d15100f/history
|
GET {{baseUrl}}/submissions/1/history
|
||||||
Authorization: Bearer {{$global.accessToken}}
|
Authorization: Bearer {{$global.accessToken}}
|
||||||
|
|
||||||
GET {{baseUrl}}/submissions
|
GET {{baseUrl}}/submissions
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
POST {{baseUrl}}/submissions/start
|
POST {{baseUrl}}/submissions/start
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
# Authorization: Bearer {{$global.accessToken}}
|
Authorization: Bearer {{$global.accessToken}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"testId": 3
|
"testId": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
POST {{baseUrl}}/submissions/6183e332-d28d-45ba-90a7-942f9d15100f/answer
|
POST {{baseUrl}}/submissions/2/answer
|
||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
# Authorization: Bearer {{$global.accessToken}}
|
Authorization: Bearer {{$global.accessToken}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"choiceId": 57
|
"choiceId": 33
|
||||||
// "numericValue": 10
|
// "numericValue": 1
|
||||||
// "choiceIds": [45]
|
// "choiceIds": []
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
GET {{baseUrl}}/tests
|
GET {{baseUrl}}/tests
|
||||||
|
|
||||||
GET {{baseUrl}}/tests/4
|
GET {{baseUrl}}/tests/1
|
||||||
|
|||||||
Reference in New Issue
Block a user