Test refactoring, make test more stable (#374)

- Move copy-pasted code to User API
- Clean the database after each test
- Refactor documents search test
This commit is contained in:
Anton Shepilov
2024-02-26 00:04:04 +01:00
committed by GitHub
parent 488aafe284
commit e0aca9dcd5
20 changed files with 719 additions and 909 deletions
@@ -165,7 +165,18 @@ export class PostgresConnector extends AbstractConnector<PostgresConnectionOptio
}
async drop(): Promise<this> {
logger.info("Drop database is not implemented for security reasons.");
const query = `
DO $$
DECLARE
tablename text;
BEGIN
FOR tablename IN (SELECT table_name FROM information_schema.tables WHERE table_schema = 'public')
LOOP
EXECUTE 'DELETE FROM "' || tablename || '" CASCADE';
END LOOP;
END $$;`;
logger.debug(`service.database.orm.postgres.drop - Query: "${query}"`);
await this.client.query(query);
return this;
}