UNPKG

n8n-nodes-databricks

Version:

Databricks node for n8n

57 lines 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = require("../config"); describe('Vector Store Config', () => { const originalEnv = { ...process.env }; afterEach(() => { process.env = { ...originalEnv }; }); describe('getConfig', () => { it('should return default values when no environment variables set', () => { delete process.env.N8N_VECTOR_STORE_MAX_MEMORY; delete process.env.N8N_VECTOR_STORE_TTL_HOURS; const config = (0, config_1.getConfig)(); expect(config.maxMemoryMB).toBe(-1); expect(config.ttlHours).toBe(-1); }); it('should use values from environment variables when set', () => { process.env.N8N_VECTOR_STORE_MAX_MEMORY = '200'; process.env.N8N_VECTOR_STORE_TTL_HOURS = '24'; const config = (0, config_1.getConfig)(); expect(config.maxMemoryMB).toBe(200); expect(config.ttlHours).toBe(24); }); it('should handle invalid environment variable values', () => { process.env.N8N_VECTOR_STORE_MAX_MEMORY = 'invalid'; process.env.N8N_VECTOR_STORE_TTL_HOURS = 'notanumber'; const config = (0, config_1.getConfig)(); expect(config.maxMemoryMB).toBe(-1); expect(config.ttlHours).toBe(-1); }); }); describe('mbToBytes', () => { it('should convert MB to bytes', () => { expect((0, config_1.mbToBytes)(1)).toBe(1024 * 1024); expect((0, config_1.mbToBytes)(5)).toBe(5 * 1024 * 1024); expect((0, config_1.mbToBytes)(100)).toBe(100 * 1024 * 1024); }); it('should handle zero and negative values', () => { expect((0, config_1.mbToBytes)(0)).toBe(-1); expect((0, config_1.mbToBytes)(-1)).toBe(-1); expect((0, config_1.mbToBytes)(-10)).toBe(-1); }); }); describe('hoursToMs', () => { it('should convert hours to milliseconds', () => { expect((0, config_1.hoursToMs)(1)).toBe(60 * 60 * 1000); expect((0, config_1.hoursToMs)(24)).toBe(24 * 60 * 60 * 1000); expect((0, config_1.hoursToMs)(168)).toBe(168 * 60 * 60 * 1000); }); it('should handle zero and negative values', () => { expect((0, config_1.hoursToMs)(0)).toBe(-1); expect((0, config_1.hoursToMs)(-1)).toBe(-1); expect((0, config_1.hoursToMs)(-24)).toBe(-1); }); }); }); //# sourceMappingURL=config.test.js.map