fix: Add missing tests directory and files
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-03 08:11:31 +00:00
parent ba3d38abbd
commit 83e5ca1dbb

63
tests/unit/config.test.ts Normal file
View File

@@ -0,0 +1,63 @@
import { validateGlobalConfig, validateWorkspaceConfig } from '../../src/config';
describe('validateGlobalConfig', () => {
it('should accept valid config', () => {
const config = {
workspacePath: './workspaces',
defaultBranch: 'main',
autoInstall: true,
templates: { default: '/templates/default' }
};
expect(() => validateGlobalConfig(config)).not.toThrow();
});
it('should use defaults for missing values', () => {
const config = {};
const validated = validateGlobalConfig(config);
expect(validated.workspacePath).toBe('./.agent-workspaces');
expect(validated.defaultBranch).toBe('main');
expect(validated.autoInstall).toBe(true);
});
it('should reject invalid workspace path', () => {
const config = { workspacePath: 123 };
expect(() => validateGlobalConfig(config)).toThrow();
});
it('should reject invalid autoInstall type', () => {
const config = { autoInstall: 'yes' };
expect(() => validateGlobalConfig(config)).toThrow();
});
});
describe('validateWorkspaceConfig', () => {
it('should accept valid workspace config', () => {
const config = {
agentName: 'test-agent',
branch: 'agent-test-agent',
createdAt: '2024-01-15T10:30:00Z',
mainBranch: 'main',
environment: { AGENT_ID: 'test-agent' }
};
expect(() => validateWorkspaceConfig(config)).not.toThrow();
});
it('should reject missing agent name', () => {
const config = {
branch: 'agent-test',
createdAt: new Date().toISOString(),
mainBranch: 'main'
};
expect(() => validateWorkspaceConfig(config)).toThrow();
});
it('should reject invalid date format', () => {
const config = {
agentName: 'test',
branch: 'agent-test',
createdAt: 'not-a-date',
mainBranch: 'main'
};
expect(() => validateWorkspaceConfig(config)).toThrow();
});
});