Skip to content

Commit

Permalink
✅ Test refactoring, make test more stable (#374)
Browse files Browse the repository at this point in the history
- Move copy-pasted code to User API
- Clean the database after each test
- Refactor documents search test
  • Loading branch information
shepilov authored Feb 25, 2024
1 parent 488aafe commit e0aca9d
Show file tree
Hide file tree
Showing 20 changed files with 719 additions and 909 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 1 addition & 5 deletions tdrive/backend/node/src/services/documents/services/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 1 addition & 3 deletions tdrive/backend/node/src/services/files/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading

0 comments on commit e0aca9d

Please sign in to comment.