Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions src/services/agent-volumes-logs.test.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { generateDockerCompose, WrapperConfig, baseConfig, mockNetworkConfig, useTempWorkDir } from './service-test-setup.test-utils';
import { generateDockerCompose, WrapperConfig, mockNetworkConfig, useAgentVolumesTestConfig } from './service-test-setup.test-utils';

// Create mock functions (must remain per-file — jest.mock() is hoisted before imports)

// eslint-disable-next-line @typescript-eslint/no-require-imports
jest.mock('execa', () => require('../test-helpers/mock-execa.test-utils').execaMockFactory());

let mockConfig: WrapperConfig;
const { getConfig } = useAgentVolumesTestConfig();

describe('agent service', () => {
useTempWorkDir(
baseConfig,
(config) => {
mockConfig = config;
},
() => mockConfig
);

describe('proxyLogsDir option', () => {
it('should use proxyLogsDir when specified', () => {
const config: WrapperConfig = {
...mockConfig,
...getConfig(),
proxyLogsDir: '/custom/proxy/logs',
};
const result = generateDockerCompose(config, mockNetworkConfig);
Expand All @@ -29,15 +21,15 @@ describe('agent service', () => {
});

it('should use workDir/squid-logs when proxyLogsDir is not specified', () => {
const result = generateDockerCompose(mockConfig, mockNetworkConfig);
const result = generateDockerCompose(getConfig(), mockNetworkConfig);
const squid = result.services['squid-proxy'];

expect(squid.volumes).toContain(`${mockConfig.workDir}/squid-logs:/var/log/squid:rw`);
expect(squid.volumes).toContain(`${getConfig().workDir}/squid-logs:/var/log/squid:rw`);
});

it('should use api-proxy-logs subdirectory inside proxyLogsDir when specified', () => {
const config: WrapperConfig = {
...mockConfig,
...getConfig(),
proxyLogsDir: '/custom/proxy/logs',
enableApiProxy: true,
openaiApiKey: 'sk-test-key',
Expand All @@ -53,7 +45,7 @@ describe('agent service', () => {

it('should use workDir/api-proxy-logs when proxyLogsDir is not specified', () => {
const config: WrapperConfig = {
...mockConfig,
...getConfig(),
enableApiProxy: true,
openaiApiKey: 'sk-test-key',
};
Expand All @@ -63,7 +55,7 @@ describe('agent service', () => {
});
const apiProxy = result.services['api-proxy'];

expect(apiProxy.volumes).toContain(`${mockConfig.workDir}/api-proxy-logs:/var/log/api-proxy:rw`);
expect(apiProxy.volumes).toContain(`${getConfig().workDir}/api-proxy-logs:/var/log/api-proxy:rw`);
});
});
});
Loading
Loading