Columbia MCP Server

import { createRedisOptions, RedisConfig, DEFAULT_LOCK_OPTIONS } from '../redis'; describe('Redis Configuration', () => { describe('createRedisOptions', () => { it('should create valid Redis options with minimal config', () => { const config: RedisConfig = { host: 'localhost', port: 6379 }; const options = createRedisOptions(config); expect(options).toEqual(expect.objectContaining({ host: 'localhost', port: 6379, db: 0, keyPrefix: '', enableReadyCheck: true, maxRetriesPerRequest: 3 })); expect(options.retryStrategy).toBeDefined(); expect(typeof options.retryStrategy).toBe('function'); }); it('should handle TLS configuration', () => { const config: RedisConfig = { host: 'localhost', port: 6379, tls: { rejectUnauthorized: false } }; const options = createRedisOptions(config); expect(options.tls).toEqual({ rejectUnauthorized: false }); }); it('should use provided password and db', () => { const config: RedisConfig = { host: 'localhost', port: 6379, password: 'secret', db: 1 }; const options = createRedisOptions(config); expect(options.password).toBe('secret'); expect(options.db).toBe(1); }); it('should handle custom key prefix', () => { const config: RedisConfig = { host: 'localhost', port: 6379, keyPrefix: 'test:' }; const options = createRedisOptions(config); expect(options.keyPrefix).toBe('test:'); }); }); describe('DEFAULT_LOCK_OPTIONS', () => { it('should have correct default values', () => { expect(DEFAULT_LOCK_OPTIONS).toEqual({ ttl: 30000, retryDelay: 100, maxRetries: 10 }); }); }); describe('retryStrategy', () => { it('should implement exponential backoff with max delay', () => { const config: RedisConfig = { host: 'localhost', port: 6379 }; const options = createRedisOptions(config); const retryStrategy = options.retryStrategy!; expect(retryStrategy(1)).toBe(50); // 1 * 50 = 50 expect(retryStrategy(10)).toBe(500); // 10 * 50 = 500 expect(retryStrategy(50)).toBe(2000); // Would be 2500, but capped at 2000 }); }); });