From 947c053c159cdfa6a520587b606740a7193d86fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Sat, 25 Jan 2025 02:38:00 -0800 Subject: [PATCH] chore(server): add DB_URL supports Unix sockets unit test (#15629) * test(server): DB_URL supports Unix sockets * chore: format --------- Co-authored-by: Alex Tran --- .../repositories/config.repository.spec.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/src/repositories/config.repository.spec.ts b/server/src/repositories/config.repository.spec.ts index 2b5343f7ba..888d5c33ec 100644 --- a/server/src/repositories/config.repository.spec.ts +++ b/server/src/repositories/config.repository.spec.ts @@ -172,6 +172,28 @@ describe('getEnv', () => { expect(() => getEnv()).toThrowError('Invalid ssl option: invalid'); }); + + it('should handle socket: URLs', () => { + process.env.DB_URL = 'socket:/run/postgresql?db=database1'; + + const { database } = getEnv(); + + expect(database.config.kysely).toMatchObject({ + host: '/run/postgresql', + database: 'database1', + }); + }); + + it('should handle sockets in postgres: URLs', () => { + process.env.DB_URL = 'postgres:///database2?host=/path/to/socket'; + + const { database } = getEnv(); + + expect(database.config.kysely).toMatchObject({ + host: '/path/to/socket', + database: 'database2', + }); + }); }); describe('redis', () => {