💄✅ backend: fix compiler issue and e2e pg connector (#525)
This commit is contained in:
committed by
ericlinagora
parent
92aad866d5
commit
e628c68229
@@ -59,8 +59,6 @@ import archiver from "archiver";
|
|||||||
import internal from "stream";
|
import internal from "stream";
|
||||||
import config from "config";
|
import config from "config";
|
||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { MultipartFile } from "@fastify/multipart";
|
|
||||||
import { UploadOptions } from "../../files/types";
|
|
||||||
|
|
||||||
export class DocumentsService {
|
export class DocumentsService {
|
||||||
version: "1";
|
version: "1";
|
||||||
|
|||||||
+22
-5
@@ -131,26 +131,43 @@ describe('The PostgresQueryBuilder', () => {
|
|||||||
const entity = newTestDbEntity();
|
const entity = newTestDbEntity();
|
||||||
|
|
||||||
const newValue = "new-tag-value";
|
const newValue = "new-tag-value";
|
||||||
const [queryText, params] = subj.buildatomicCompareAndSet(entity, "tags", null, newValue);
|
const queries = subj.buildatomicCompareAndSet(entity, "tags", null, newValue);
|
||||||
|
let queryText, params;
|
||||||
|
|
||||||
expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4 RETURNING tags`);
|
[queryText, params] = queries.updateQuery;
|
||||||
|
expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags IS NULL`);
|
||||||
expect(params[0]).toBe(JSON.stringify(newValue));
|
expect(params[0]).toBe(JSON.stringify(newValue));
|
||||||
expect(params[1]).toBe(entity.company_id);
|
expect(params[1]).toBe(entity.company_id);
|
||||||
expect(params[2]).toBe(entity.id);
|
expect(params[2]).toBe(entity.id);
|
||||||
expect(params[3]).toBe(null);
|
expect(params.length).toBe(3);
|
||||||
|
|
||||||
|
[queryText, params] = queries.getValueQuery;
|
||||||
|
expect(normalizeWhitespace(queryText as string)).toBe(`SELECT "tags" FROM "test_table" WHERE company_id = $1 AND id = $2`);
|
||||||
|
expect(params[0]).toBe(entity.company_id);
|
||||||
|
expect(params[1]).toBe(entity.id);
|
||||||
|
expect(params.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('buildatomicCompareAndSet to null', async () => {
|
test('buildatomicCompareAndSet to null', async () => {
|
||||||
const entity = newTestDbEntity();
|
const entity = newTestDbEntity();
|
||||||
|
|
||||||
const previousValue = "new-tag-value";
|
const previousValue = "new-tag-value";
|
||||||
const [queryText, params] = subj.buildatomicCompareAndSet(entity, "tags", previousValue, null);
|
const queries = subj.buildatomicCompareAndSet(entity, "tags", previousValue, null);
|
||||||
|
let queryText, params;
|
||||||
|
|
||||||
expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4 RETURNING tags`);
|
[queryText, params] = queries.updateQuery;
|
||||||
|
expect(normalizeWhitespace(queryText as string)).toBe(`UPDATE "test_table" SET tags = $1 WHERE company_id = $2 AND id = $3 AND tags = $4`);
|
||||||
expect(params[0]).toBe(null);
|
expect(params[0]).toBe(null);
|
||||||
expect(params[1]).toBe(entity.company_id);
|
expect(params[1]).toBe(entity.company_id);
|
||||||
expect(params[2]).toBe(entity.id);
|
expect(params[2]).toBe(entity.id);
|
||||||
expect(params[3]).toBe(JSON.stringify(previousValue));
|
expect(params[3]).toBe(JSON.stringify(previousValue));
|
||||||
|
expect(params.length).toBe(4);
|
||||||
|
|
||||||
|
[queryText, params] = queries.getValueQuery;
|
||||||
|
expect(normalizeWhitespace(queryText as string)).toBe(`SELECT "tags" FROM "test_table" WHERE company_id = $1 AND id = $2`);
|
||||||
|
expect(params[0]).toBe(entity.company_id);
|
||||||
|
expect(params[1]).toBe(entity.id);
|
||||||
|
expect(params.length).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
const assertInsertQueryParams = (actual: TestDbEntity, expected: any[]) => {
|
const assertInsertQueryParams = (actual: TestDbEntity, expected: any[]) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user