tests
This commit is contained in:
parent
3a7254708e
commit
b63e58784c
41 changed files with 5762 additions and 4477 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import { asClass, asFunction, asValue, createContainer } from 'awilix';
|
||||
import { describe, expect, it, mock } from 'bun:test';
|
||||
import { createContainer, asClass, asFunction, asValue } from 'awilix';
|
||||
import {
|
||||
registerApplicationServices,
|
||||
registerCacheServices,
|
||||
registerDatabaseServices,
|
||||
registerApplicationServices,
|
||||
} from '../src/registrations';
|
||||
|
||||
describe('DI Registrations', () => {
|
||||
|
|
@ -30,7 +30,7 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register redis cache when redis config exists', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Register logger first as it's a dependency
|
||||
container.register({
|
||||
logger: asValue({
|
||||
|
|
@ -62,7 +62,7 @@ describe('DI Registrations', () => {
|
|||
|
||||
it('should register both cache and globalCache', () => {
|
||||
const container = createContainer();
|
||||
|
||||
|
||||
// Register logger dependency
|
||||
container.register({
|
||||
logger: asValue({
|
||||
|
|
@ -120,7 +120,14 @@ describe('DI Registrations', () => {
|
|||
database: 'test-db',
|
||||
},
|
||||
redis: { enabled: false, host: 'localhost', port: 6379 },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
} as any;
|
||||
|
||||
registerDatabaseServices(container, config);
|
||||
|
|
@ -183,7 +190,14 @@ describe('DI Registrations', () => {
|
|||
database: 'test',
|
||||
},
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
redis: { enabled: false, host: 'localhost', port: 6379 },
|
||||
} as any;
|
||||
|
||||
|
|
@ -201,7 +215,14 @@ describe('DI Registrations', () => {
|
|||
type: 'WORKER' as const,
|
||||
},
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
redis: { enabled: false, host: 'localhost', port: 6379 },
|
||||
// questdb is optional
|
||||
} as any;
|
||||
|
|
@ -237,7 +258,14 @@ describe('DI Registrations', () => {
|
|||
},
|
||||
redis: { enabled: true, host: 'localhost', port: 6379 },
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
|
@ -266,7 +294,14 @@ describe('DI Registrations', () => {
|
|||
},
|
||||
redis: { enabled: true, host: 'localhost', port: 6379 },
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
|
@ -303,7 +338,14 @@ describe('DI Registrations', () => {
|
|||
port: 6379,
|
||||
},
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
|
@ -328,7 +370,14 @@ describe('DI Registrations', () => {
|
|||
port: 6379,
|
||||
},
|
||||
mongodb: { enabled: false, uri: 'mongodb://localhost', database: 'test' },
|
||||
postgres: { enabled: false, host: 'localhost', port: 5432, database: 'test', user: 'test', password: 'test' },
|
||||
postgres: {
|
||||
enabled: false,
|
||||
host: 'localhost',
|
||||
port: 5432,
|
||||
database: 'test',
|
||||
user: 'test',
|
||||
password: 'test',
|
||||
},
|
||||
} as any;
|
||||
|
||||
registerApplicationServices(container, config);
|
||||
|
|
@ -338,4 +387,4 @@ describe('DI Registrations', () => {
|
|||
expect(container.resolve('queueManager')).toBeNull();
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue