fix(config): warn on ignored legacy config keys
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { assertEquals } from 'jsr:@std/assert@^1.0.0';
|
||||
import { ConfigManager } from '../ts/config/config-manager.ts';
|
||||
import type { IModelGridConfig } from '../ts/interfaces/config.ts';
|
||||
import { logger } from '../ts/logger.ts';
|
||||
|
||||
Deno.test('ConfigManager normalizes current config defaults', () => {
|
||||
const configManager = new ConfigManager();
|
||||
@@ -46,3 +47,73 @@ Deno.test('ConfigManager normalizes current config defaults', () => {
|
||||
assertEquals(normalized.ui.port, 8081);
|
||||
assertEquals(normalized.ui.assetSource, 'bundle');
|
||||
});
|
||||
|
||||
Deno.test('ConfigManager warns when config contains ignored keys', () => {
|
||||
const configManager = new ConfigManager();
|
||||
const warnings: string[] = [];
|
||||
const originalWarn = logger.warn;
|
||||
logger.warn = (message: string) => {
|
||||
warnings.push(message);
|
||||
};
|
||||
|
||||
try {
|
||||
configManager.normalizeConfig({
|
||||
version: '1.0.0',
|
||||
api: {
|
||||
port: 8080,
|
||||
host: '127.0.0.1',
|
||||
apiKeys: [],
|
||||
},
|
||||
docker: {
|
||||
networkName: 'modelgrid',
|
||||
runtime: 'docker',
|
||||
},
|
||||
gpus: {
|
||||
autoDetect: true,
|
||||
assignments: {},
|
||||
},
|
||||
containers: [
|
||||
{ id: 'legacy', type: 'ollama' } as never,
|
||||
],
|
||||
models: {
|
||||
registryUrl: 'https://example.com/catalog.json',
|
||||
autoDeploy: true,
|
||||
defaultEngine: 'vllm',
|
||||
autoLoad: [],
|
||||
greenlistUrl: 'https://legacy.example.com/catalog.json',
|
||||
autoPull: true,
|
||||
defaultContainer: 'legacy-container',
|
||||
} as IModelGridConfig['models'] & {
|
||||
greenlistUrl: string;
|
||||
autoPull: boolean;
|
||||
defaultContainer: string;
|
||||
},
|
||||
cluster: {
|
||||
enabled: false,
|
||||
nodeName: 'modelgrid-local',
|
||||
role: 'standalone',
|
||||
bindHost: '0.0.0.0',
|
||||
gossipPort: 7946,
|
||||
heartbeatIntervalMs: 5000,
|
||||
seedNodes: [],
|
||||
},
|
||||
checkInterval: 30000,
|
||||
legacySection: true,
|
||||
} as Partial<IModelGridConfig> & {
|
||||
legacySection: boolean;
|
||||
models: IModelGridConfig['models'] & {
|
||||
greenlistUrl: string;
|
||||
autoPull: boolean;
|
||||
defaultContainer: string;
|
||||
};
|
||||
});
|
||||
} finally {
|
||||
logger.warn = originalWarn;
|
||||
}
|
||||
|
||||
assertEquals(warnings.includes('Ignoring unknown config key: legacySection'), true);
|
||||
assertEquals(warnings.includes('Ignoring removed config key: models.greenlistUrl'), true);
|
||||
assertEquals(warnings.includes('Ignoring removed config key: models.autoPull'), true);
|
||||
assertEquals(warnings.includes('Ignoring removed config key: models.defaultContainer'), true);
|
||||
assertEquals(warnings.includes('Ignoring unsupported container type: ollama'), true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user