renaming services to more suitable names
This commit is contained in:
parent
3ae9de8376
commit
be6afef832
69 changed files with 41 additions and 2956 deletions
|
|
@ -1,18 +1,17 @@
|
|||
import { describe, test, expect, beforeEach, afterEach } from 'bun:test';
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { mkdirSync, writeFileSync, rmSync, existsSync } from 'fs';
|
||||
import {
|
||||
initializeConfig,
|
||||
initializeServiceConfig,
|
||||
getConfig,
|
||||
import {
|
||||
getConfig,
|
||||
getDatabaseConfig,
|
||||
getServiceConfig,
|
||||
getLoggingConfig,
|
||||
getProviderConfig,
|
||||
getServiceConfig,
|
||||
initializeServiceConfig,
|
||||
isDevelopment,
|
||||
isProduction,
|
||||
isTest,
|
||||
resetConfig
|
||||
resetConfig
|
||||
} from '../src/index';
|
||||
|
||||
const TEST_DIR = join(__dirname, 'real-usage-tests');
|
||||
|
|
@ -44,15 +43,15 @@ describe('Real Usage Scenarios', () => {
|
|||
}
|
||||
});
|
||||
|
||||
test('should work like real data-service usage', async () => {
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
test('should work like real data-ingestion usage', async () => {
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
// Simulate how data-service would initialize config
|
||||
// Simulate how data-ingestion would initialize config
|
||||
const config = await initializeServiceConfig();
|
||||
|
||||
// Test typical data-service config access patterns
|
||||
expect(config.app.name).toBe('data-service');
|
||||
// Test typical data-ingestion config access patterns
|
||||
expect(config.app.name).toBe('data-ingestion');
|
||||
expect(config.service.port).toBe(3001);
|
||||
|
||||
// Test database config access
|
||||
|
|
@ -108,7 +107,7 @@ describe('Real Usage Scenarios', () => {
|
|||
test('should handle production environment correctly', async () => {
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
resetConfig();
|
||||
|
|
@ -124,7 +123,7 @@ describe('Real Usage Scenarios', () => {
|
|||
test('should handle test environment correctly', async () => {
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
resetConfig();
|
||||
|
|
@ -144,7 +143,7 @@ describe('Real Usage Scenarios', () => {
|
|||
process.env.EOD_API_KEY = 'prod-eod-key';
|
||||
process.env.SERVICE_PORT = '8080';
|
||||
|
||||
const dataServiceDir = join(TEST_ROOT, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_ROOT, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
resetConfig();
|
||||
|
|
@ -163,7 +162,7 @@ describe('Real Usage Scenarios', () => {
|
|||
});
|
||||
|
||||
test('should handle missing provider configurations gracefully', async () => {
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
const config = await initializeServiceConfig();
|
||||
|
|
@ -178,7 +177,7 @@ describe('Real Usage Scenarios', () => {
|
|||
});
|
||||
|
||||
test('should support dynamic config access patterns', async () => {
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
const config = await initializeServiceConfig();
|
||||
|
|
@ -187,7 +186,7 @@ describe('Real Usage Scenarios', () => {
|
|||
const configManager = (await import('../src/index')).getConfigManager();
|
||||
|
||||
// Direct path access
|
||||
expect(configManager.getValue('app.name')).toBe('data-service');
|
||||
expect(configManager.getValue('app.name')).toBe('data-ingestion');
|
||||
expect(configManager.getValue('service.port')).toBe(3001);
|
||||
|
||||
// Check if paths exist
|
||||
|
|
@ -201,7 +200,7 @@ describe('Real Usage Scenarios', () => {
|
|||
});
|
||||
|
||||
test('should handle config updates at runtime', async () => {
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
await initializeServiceConfig();
|
||||
|
|
@ -218,18 +217,18 @@ describe('Real Usage Scenarios', () => {
|
|||
expect(updatedConfig.service.port).toBe(9999);
|
||||
|
||||
// Other values should be preserved
|
||||
expect(updatedConfig.app.name).toBe('data-service');
|
||||
expect(updatedConfig.app.name).toBe('data-ingestion');
|
||||
});
|
||||
|
||||
test('should work across multiple service initializations', async () => {
|
||||
// Simulate multiple services in the same process (like tests)
|
||||
|
||||
// First service
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-service');
|
||||
const dataServiceDir = join(TEST_DIR, 'apps', 'data-ingestion');
|
||||
process.chdir(dataServiceDir);
|
||||
|
||||
let config = await initializeServiceConfig();
|
||||
expect(config.app.name).toBe('data-service');
|
||||
expect(config.app.name).toBe('data-ingestion');
|
||||
|
||||
// Reset and switch to another service
|
||||
resetConfig();
|
||||
|
|
@ -249,7 +248,7 @@ const TEST_ROOT = TEST_DIR;
|
|||
function setupRealUsageScenarios() {
|
||||
const scenarios = {
|
||||
root: TEST_ROOT,
|
||||
dataService: join(TEST_ROOT, 'apps', 'data-service'),
|
||||
dataService: join(TEST_ROOT, 'apps', 'data-ingestion'),
|
||||
webApi: join(TEST_ROOT, 'apps', 'web-api'),
|
||||
cacheLib: join(TEST_ROOT, 'libs', 'cache'),
|
||||
};
|
||||
|
|
@ -344,10 +343,10 @@ function setupRealUsageScenarios() {
|
|||
join(scenarios.dataService, 'config', 'development.json'),
|
||||
JSON.stringify({
|
||||
app: {
|
||||
name: 'data-service'
|
||||
name: 'data-ingestion'
|
||||
},
|
||||
service: {
|
||||
name: 'data-service',
|
||||
name: 'data-ingestion',
|
||||
port: 3001,
|
||||
workers: 2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ bun add @stock-bot/event-bus
|
|||
import { createEventBus, TradingEventType } from '@stock-bot/event-bus';
|
||||
|
||||
const eventBus = createEventBus({
|
||||
serviceName: 'data-service',
|
||||
serviceName: 'data-ingestion',
|
||||
redisConfig: {
|
||||
host: 'localhost',
|
||||
port: 6379,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue