|
|
@@ -387,6 +387,36 @@ describe('onWarning callback', () => {
|
|
|
expect(config.agents?.oracle?.model).toBe('root');
|
|
|
});
|
|
|
|
|
|
+ test('silent: true on missing preset still calls onWarning but not console.warn', () => {
|
|
|
+ const projectDir = path.join(tempDir, 'project');
|
|
|
+ const projectConfigDir = path.join(projectDir, '.opencode');
|
|
|
+ fs.mkdirSync(projectConfigDir, { recursive: true });
|
|
|
+ fs.writeFileSync(
|
|
|
+ path.join(projectConfigDir, 'oh-my-opencode-slim.json'),
|
|
|
+ JSON.stringify({
|
|
|
+ preset: 'nonexistent',
|
|
|
+ presets: { other: { oracle: { model: 'other' } } },
|
|
|
+ agents: { oracle: { model: 'root' } },
|
|
|
+ }),
|
|
|
+ );
|
|
|
+
|
|
|
+ const warnSpy = spyOn(console, 'warn').mockImplementation(() => {});
|
|
|
+ try {
|
|
|
+ const warnings: ConfigLoadWarning[] = [];
|
|
|
+ const config = loadPluginConfig(projectDir, {
|
|
|
+ silent: true,
|
|
|
+ onWarning: (warning) => warnings.push(warning),
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(warnings).toHaveLength(1);
|
|
|
+ expect(warnings[0]?.kind).toBe('missing-preset');
|
|
|
+ expect(config.agents?.oracle?.model).toBe('root');
|
|
|
+ expect(warnSpy).not.toHaveBeenCalled();
|
|
|
+ } finally {
|
|
|
+ warnSpy.mockRestore();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
test('valid config does not call onWarning', () => {
|
|
|
const projectDir = path.join(tempDir, 'project');
|
|
|
const projectConfigDir = path.join(projectDir, '.opencode');
|