fixed format issues

This commit is contained in:
Boki 2025-06-26 16:12:27 -04:00
parent a700818a06
commit 08f713d98b
55 changed files with 5680 additions and 5533 deletions

View file

@ -1,27 +1,27 @@
import { describe, it, expect } from 'bun:test';
import { describe, expect, it } from 'bun:test';
import { z } from 'zod';
import {
baseConfigSchema,
environmentSchema,
serviceConfigSchema,
loggingConfigSchema,
queueConfigSchema,
httpConfigSchema,
webshareConfigSchema,
browserConfigSchema,
proxyConfigSchema,
postgresConfigSchema,
questdbConfigSchema,
mongodbConfigSchema,
dragonflyConfigSchema,
databaseConfigSchema,
baseProviderConfigSchema,
browserConfigSchema,
databaseConfigSchema,
dragonflyConfigSchema,
environmentSchema,
eodProviderConfigSchema,
httpConfigSchema,
ibProviderConfigSchema,
qmProviderConfigSchema,
yahooProviderConfigSchema,
webshareProviderConfigSchema,
loggingConfigSchema,
mongodbConfigSchema,
postgresConfigSchema,
providerConfigSchema,
proxyConfigSchema,
qmProviderConfigSchema,
questdbConfigSchema,
queueConfigSchema,
serviceConfigSchema,
webshareConfigSchema,
webshareProviderConfigSchema,
yahooProviderConfigSchema,
} from '../src/schemas';
describe('Config Schemas', () => {
@ -202,7 +202,7 @@ describe('Config Schemas', () => {
describe('queueConfigSchema', () => {
it('should accept minimal config with defaults', () => {
const config = queueConfigSchema.parse({
redis: {}, // redis is required, but its properties have defaults
redis: {}, // redis is required, but its properties have defaults
});
expect(config).toEqual({
enabled: true,
@ -421,7 +421,7 @@ describe('Config Schemas', () => {
// Empty strings are allowed by z.string() unless .min(1) is specified
const serviceConfig = serviceConfigSchema.parse({ name: '', port: 3000 });
expect(serviceConfig.name).toBe('');
const baseConfig = baseConfigSchema.parse({ name: '' });
expect(baseConfig.name).toBe('');
});
@ -493,19 +493,23 @@ describe('Config Schemas', () => {
});
it('should validate poolSize range', () => {
expect(() => postgresConfigSchema.parse({
database: 'testdb',
user: 'testuser',
password: 'testpass',
poolSize: 0,
})).toThrow();
expect(() => postgresConfigSchema.parse({
database: 'testdb',
user: 'testuser',
password: 'testpass',
poolSize: 101,
})).toThrow();
expect(() =>
postgresConfigSchema.parse({
database: 'testdb',
user: 'testuser',
password: 'testpass',
poolSize: 0,
})
).toThrow();
expect(() =>
postgresConfigSchema.parse({
database: 'testdb',
user: 'testuser',
password: 'testpass',
poolSize: 101,
})
).toThrow();
});
});
@ -574,24 +578,30 @@ describe('Config Schemas', () => {
});
it('should validate URI format', () => {
expect(() => mongodbConfigSchema.parse({
uri: 'invalid-uri',
database: 'testdb',
})).toThrow();
expect(() =>
mongodbConfigSchema.parse({
uri: 'invalid-uri',
database: 'testdb',
})
).toThrow();
});
it('should validate poolSize range', () => {
expect(() => mongodbConfigSchema.parse({
uri: 'mongodb://localhost',
database: 'testdb',
poolSize: 0,
})).toThrow();
expect(() => mongodbConfigSchema.parse({
uri: 'mongodb://localhost',
database: 'testdb',
poolSize: 101,
})).toThrow();
expect(() =>
mongodbConfigSchema.parse({
uri: 'mongodb://localhost',
database: 'testdb',
poolSize: 0,
})
).toThrow();
expect(() =>
mongodbConfigSchema.parse({
uri: 'mongodb://localhost',
database: 'testdb',
poolSize: 101,
})
).toThrow();
});
});
@ -645,7 +655,7 @@ describe('Config Schemas', () => {
},
dragonfly: {},
});
expect(config.postgres.host).toBe('localhost');
expect(config.questdb.enabled).toBe(true);
expect(config.mongodb.poolSize).toBe(10);
@ -703,11 +713,13 @@ describe('Config Schemas', () => {
});
it('should validate tier values', () => {
expect(() => eodProviderConfigSchema.parse({
name: 'eod',
apiKey: 'test-key',
tier: 'premium',
})).toThrow();
expect(() =>
eodProviderConfigSchema.parse({
name: 'eod',
apiKey: 'test-key',
tier: 'premium',
})
).toThrow();
const validTiers = ['free', 'fundamentals', 'all-in-one'];
for (const tier of validTiers) {
@ -759,10 +771,12 @@ describe('Config Schemas', () => {
});
it('should validate marketDataType', () => {
expect(() => ibProviderConfigSchema.parse({
name: 'ib',
marketDataType: 'realtime',
})).toThrow();
expect(() =>
ibProviderConfigSchema.parse({
name: 'ib',
marketDataType: 'realtime',
})
).toThrow();
const validTypes = ['live', 'delayed', 'frozen'];
for (const type of validTypes) {
@ -777,9 +791,11 @@ describe('Config Schemas', () => {
describe('qmProviderConfigSchema', () => {
it('should require all credentials', () => {
expect(() => qmProviderConfigSchema.parse({
name: 'qm',
})).toThrow();
expect(() =>
qmProviderConfigSchema.parse({
name: 'qm',
})
).toThrow();
const config = qmProviderConfigSchema.parse({
name: 'qm',
@ -885,7 +901,7 @@ describe('Config Schemas', () => {
apiKey: 'ws-key',
},
});
expect(config.eod?.tier).toBe('all-in-one');
expect(config.ib?.gateway.port).toBe(7497);
expect(config.qm?.username).toBe('user');
@ -893,4 +909,4 @@ describe('Config Schemas', () => {
expect(config.webshare?.apiKey).toBe('ws-key');
});
});
});
});