fix(tests): update tests and test helpers to current email/DNS APIs, use non-privileged ports, and improve robustness and resilience
This commit is contained in:
@@ -58,7 +58,7 @@ tap.test('DcRouter class - Custom email port configuration', async () => {
|
||||
// Ensure directory exists and is empty
|
||||
if (fs.existsSync(customEmailsPath)) {
|
||||
try {
|
||||
fs.rmdirSync(customEmailsPath, { recursive: true });
|
||||
fs.rmSync(customEmailsPath, { recursive: true });
|
||||
} catch (e) {
|
||||
console.warn('Could not remove test directory:', e);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ tap.test('DcRouter class - Custom email port configuration', async () => {
|
||||
|
||||
// Clean up
|
||||
try {
|
||||
fs.rmdirSync(customEmailsPath, { recursive: true });
|
||||
fs.rmSync(customEmailsPath, { recursive: true });
|
||||
} catch (e) {
|
||||
console.warn('Could not remove test directory in cleanup:', e);
|
||||
}
|
||||
@@ -132,23 +132,24 @@ tap.test('DcRouter class - Custom email port configuration', async () => {
|
||||
tap.test('DcRouter class - Custom email storage path', async () => {
|
||||
// Create custom email storage path
|
||||
const customEmailsPath = path.join(process.cwd(), 'email');
|
||||
|
||||
|
||||
// Ensure directory exists and is empty
|
||||
if (fs.existsSync(customEmailsPath)) {
|
||||
try {
|
||||
fs.rmdirSync(customEmailsPath, { recursive: true });
|
||||
fs.rmSync(customEmailsPath, { recursive: true });
|
||||
} catch (e) {
|
||||
console.warn('Could not remove test directory:', e);
|
||||
}
|
||||
}
|
||||
fs.mkdirSync(customEmailsPath, { recursive: true });
|
||||
|
||||
|
||||
// Create a basic email configuration
|
||||
// Use high port (2525) to avoid needing root privileges
|
||||
const emailConfig: IEmailConfig = {
|
||||
ports: [25],
|
||||
ports: [2525],
|
||||
hostname: 'mail.example.com',
|
||||
defaultMode: 'mta' as EmailProcessingMode,
|
||||
domainRules: []
|
||||
domains: [], // Required: domain configurations
|
||||
routes: [] // Required: email routing rules
|
||||
};
|
||||
|
||||
// Create DcRouter options with custom email storage path
|
||||
@@ -175,14 +176,14 @@ tap.test('DcRouter class - Custom email storage path', async () => {
|
||||
expect(fs.existsSync(customEmailsPath)).toEqual(true);
|
||||
|
||||
// Verify unified email server was initialized
|
||||
expect(router.unifiedEmailServer).toBeTruthy();
|
||||
expect(router.emailServer).toBeTruthy();
|
||||
|
||||
// Stop the router
|
||||
await router.stop();
|
||||
|
||||
// Clean up
|
||||
try {
|
||||
fs.rmdirSync(customEmailsPath, { recursive: true });
|
||||
fs.rmSync(customEmailsPath, { recursive: true });
|
||||
} catch (e) {
|
||||
console.warn('Could not remove test directory in cleanup:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user