✅ 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:
+12
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import SearchRepository from "../../../core/platform/services/search/repository";
|
||||
import { getLogger, logger, TdriveLogger } from "../../../core/platform/framework";
|
||||
import {
|
||||
CrudException,
|
||||
ExecutionContext,
|
||||
ListResult,
|
||||
} from "../../../core/platform/framework/api/crud-service";
|
||||
import { CrudException, ListResult } from "../../../core/platform/framework/api/crud-service";
|
||||
import Repository, {
|
||||
comparisonType,
|
||||
inType,
|
||||
|
||||
@@ -311,7 +311,5 @@ export class FileServiceImpl {
|
||||
}
|
||||
|
||||
function getFilePath(entity: File): string {
|
||||
return `${gr.platformServices.storage.getHomeDir()}/files/${entity.company_id}/${
|
||||
entity.user_id || "anonymous"
|
||||
}/${entity.id}`;
|
||||
return `/files/${entity.company_id}/${entity.user_id || "anonymous"}/${entity.id}`;
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ import { getPublicUserRoom, getUserRoom } from "../../realtime";
|
||||
import NodeCache from "node-cache";
|
||||
import gr from "../../../global-resolver";
|
||||
import { formatUser } from "../../../../utils/users";
|
||||
import { getDefaultDriveItem } from "../../../documents/utils";
|
||||
import { CompanyExecutionContext } from "../../../documents/types";
|
||||
import { TYPE as DriveFileType, DriveFile } from "../../../documents/entities/drive-file";
|
||||
import config from "config";
|
||||
|
||||
export class UserServiceImpl {
|
||||
version: "1";
|
||||
|
||||
Reference in New Issue
Block a user