fixed format issues
This commit is contained in:
parent
a700818a06
commit
08f713d98b
55 changed files with 5680 additions and 5533 deletions
188
libs/core/cache/test/connection-manager.test.ts
vendored
188
libs/core/cache/test/connection-manager.test.ts
vendored
|
|
@ -1,94 +1,94 @@
|
|||
import { describe, it, expect } from 'bun:test';
|
||||
import { RedisConnectionManager } from '../src/connection-manager';
|
||||
|
||||
describe('RedisConnectionManager', () => {
|
||||
it('should be a singleton', () => {
|
||||
const instance1 = RedisConnectionManager.getInstance();
|
||||
const instance2 = RedisConnectionManager.getInstance();
|
||||
expect(instance1).toBe(instance2);
|
||||
});
|
||||
|
||||
it('should create connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
const connection = manager.getConnection({
|
||||
name: 'test',
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(connection).toBeDefined();
|
||||
expect(connection.options.host).toBe('localhost');
|
||||
expect(connection.options.port).toBe(6379);
|
||||
});
|
||||
|
||||
it('should reuse singleton connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
const conn1 = manager.getConnection({
|
||||
name: 'shared',
|
||||
singleton: true,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
const conn2 = manager.getConnection({
|
||||
name: 'shared',
|
||||
singleton: true,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(conn1).toBe(conn2);
|
||||
});
|
||||
|
||||
it('should create separate non-singleton connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
const conn1 = manager.getConnection({
|
||||
name: 'separate1',
|
||||
singleton: false,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
const conn2 = manager.getConnection({
|
||||
name: 'separate2',
|
||||
singleton: false,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(conn1).not.toBe(conn2);
|
||||
});
|
||||
|
||||
it('should close all connections', async () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
// Create a few connections
|
||||
manager.getConnection({
|
||||
name: 'close-test-1',
|
||||
redisConfig: { host: 'localhost', port: 6379 },
|
||||
});
|
||||
|
||||
manager.getConnection({
|
||||
name: 'close-test-2',
|
||||
redisConfig: { host: 'localhost', port: 6379 },
|
||||
});
|
||||
|
||||
// Close all
|
||||
await RedisConnectionManager.closeAll();
|
||||
|
||||
// Should not throw
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { RedisConnectionManager } from '../src/connection-manager';
|
||||
|
||||
describe('RedisConnectionManager', () => {
|
||||
it('should be a singleton', () => {
|
||||
const instance1 = RedisConnectionManager.getInstance();
|
||||
const instance2 = RedisConnectionManager.getInstance();
|
||||
expect(instance1).toBe(instance2);
|
||||
});
|
||||
|
||||
it('should create connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
const connection = manager.getConnection({
|
||||
name: 'test',
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(connection).toBeDefined();
|
||||
expect(connection.options.host).toBe('localhost');
|
||||
expect(connection.options.port).toBe(6379);
|
||||
});
|
||||
|
||||
it('should reuse singleton connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
const conn1 = manager.getConnection({
|
||||
name: 'shared',
|
||||
singleton: true,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
const conn2 = manager.getConnection({
|
||||
name: 'shared',
|
||||
singleton: true,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(conn1).toBe(conn2);
|
||||
});
|
||||
|
||||
it('should create separate non-singleton connections', () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
const conn1 = manager.getConnection({
|
||||
name: 'separate1',
|
||||
singleton: false,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
const conn2 = manager.getConnection({
|
||||
name: 'separate2',
|
||||
singleton: false,
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
},
|
||||
});
|
||||
|
||||
expect(conn1).not.toBe(conn2);
|
||||
});
|
||||
|
||||
it('should close all connections', async () => {
|
||||
const manager = RedisConnectionManager.getInstance();
|
||||
|
||||
// Create a few connections
|
||||
manager.getConnection({
|
||||
name: 'close-test-1',
|
||||
redisConfig: { host: 'localhost', port: 6379 },
|
||||
});
|
||||
|
||||
manager.getConnection({
|
||||
name: 'close-test-2',
|
||||
redisConfig: { host: 'localhost', port: 6379 },
|
||||
});
|
||||
|
||||
// Close all
|
||||
await RedisConnectionManager.closeAll();
|
||||
|
||||
// Should not throw
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue