mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 06:17:27 +00:00
test(proxy): cover multi-profile daemon ports
This commit is contained in:
1 parent
94bf1fbfe9
commit
8942be3afc
2 files changed
+63
-5
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
|
||||
import * as fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { mutateUnifiedConfig } from '../../../src/config/unified-config-loader';
|
||||
import { resolveOpenAICompatProxyPreferredPort } from '../../../src/proxy/proxy-port-resolver';
|
||||
|
||||
let originalCcsHome: string | undefined;
|
||||
let tempDir: string;
|
||||
|
||||
beforeEach(() => {
|
||||
originalCcsHome = process.env.CCS_HOME;
|
||||
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ccs-proxy-config-'));
|
||||
process.env.CCS_HOME = tempDir;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (originalCcsHome !== undefined) {
|
||||
process.env.CCS_HOME = originalCcsHome;
|
||||
} else {
|
||||
delete process.env.CCS_HOME;
|
||||
}
|
||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
describe('resolveOpenAICompatProxyPreferredPort', () => {
|
||||
it('returns the configured profile-scoped port when present', () => {
|
||||
mutateUnifiedConfig((config) => {
|
||||
config.proxy = {
|
||||
...(config.proxy ?? {}),
|
||||
port: 3456,
|
||||
profile_ports: { ccgm: 3461 },
|
||||
};
|
||||
});
|
||||
|
||||
expect(resolveOpenAICompatProxyPreferredPort('ccgm')).toBe(3461);
|
||||
});
|
||||
|
||||
it('falls back to the shared default port when no profile mapping exists', () => {
|
||||
expect(resolveOpenAICompatProxyPreferredPort('ccg')).toBe(3456);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user