test(core): Skip SMTP tests if service unavailable (#3293)

This commit is contained in:
Iván Ovejero
2022-05-20 21:28:05 +02:00
committed by GitHub
parent 29ddac30d3
commit e7fa0ae883
3 changed files with 30 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import { credentialsController } from '../../../src/api/credentials.api';
import type { User } from '../../../src/databases/entities/User';
import type { EndpointGroup, SmtpTestAccount } from './types';
import type { N8nApp } from '../../../src/UserManagement/Interfaces';
import * as UserManagementMailer from '../../../src/UserManagement/email/UserManagementMailer';
/**
* Initialize a test server.
@@ -229,6 +230,21 @@ export async function configureSmtp() {
config.set('userManagement.emails.smtp.auth.pass', pass);
}
export async function isTestSmtpServiceAvailable() {
try {
await configureSmtp();
await UserManagementMailer.getInstance();
return true;
} catch (_) {
return false;
}
}
export function skipSmtpTest(expect: jest.Expect) {
console.warn(`SMTP service unavailable - Skipping test ${expect.getState().currentTestName}`);
return;
}
// ----------------------------------
// misc
// ----------------------------------