created lots of tests
This commit is contained in:
parent
42baadae38
commit
54f37f9521
21 changed files with 4577 additions and 215 deletions
57
libs/core/queue/test/service-cache.test.ts
Normal file
57
libs/core/queue/test/service-cache.test.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { describe, expect, it } from 'bun:test';
|
||||
import { normalizeServiceName, generateCachePrefix } from '../src/service-utils';
|
||||
|
||||
describe('ServiceCache Integration', () => {
|
||||
// Since ServiceCache depends on external createCache, we'll test the utility functions it uses
|
||||
|
||||
describe('generateCachePrefix usage', () => {
|
||||
it('should generate correct cache prefix for service', () => {
|
||||
const prefix = generateCachePrefix('userService');
|
||||
expect(prefix).toBe('cache:user-service');
|
||||
});
|
||||
|
||||
it('should handle global cache prefix', () => {
|
||||
// This simulates what ServiceCache does for global cache
|
||||
const globalPrefix = 'stock-bot:shared';
|
||||
expect(globalPrefix).toBe('stock-bot:shared');
|
||||
});
|
||||
});
|
||||
|
||||
describe('cache key patterns', () => {
|
||||
it('should follow correct key pattern for job results', () => {
|
||||
const jobId = 'job-123';
|
||||
const expectedKey = `job:result:${jobId}`;
|
||||
expect(expectedKey).toBe('job:result:job-123');
|
||||
});
|
||||
|
||||
it('should follow correct key pattern for operation metrics', () => {
|
||||
const handler = 'test-handler';
|
||||
const operation = 'test-op';
|
||||
const expectedKey = `metrics:${handler}:${operation}`;
|
||||
expect(expectedKey).toBe('metrics:test-handler:test-op');
|
||||
});
|
||||
|
||||
it('should follow correct key pattern for service health', () => {
|
||||
const serviceName = 'test-service';
|
||||
const expectedKey = `health:${serviceName}`;
|
||||
expect(expectedKey).toBe('health:test-service');
|
||||
});
|
||||
|
||||
it('should follow correct key pattern for queue stats', () => {
|
||||
const queueName = 'test-queue';
|
||||
const expectedKey = `queue:stats:${queueName}`;
|
||||
expect(expectedKey).toBe('queue:stats:test-queue');
|
||||
});
|
||||
});
|
||||
|
||||
describe('service name normalization', () => {
|
||||
it('should normalize service names in cache prefix', () => {
|
||||
const serviceName = 'UserService';
|
||||
const normalized = normalizeServiceName(serviceName);
|
||||
expect(normalized).toBe('user-service');
|
||||
|
||||
const prefix = generateCachePrefix(normalized);
|
||||
expect(prefix).toBe('cache:user-service');
|
||||
});
|
||||
});
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue