Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10360952
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/back/test_utils/with-prod-app.ts b/src/back/test_utils/with-prod-app.ts
index b936c5f..3722611 100644
--- a/src/back/test_utils/with-prod-app.ts
+++ b/src/back/test_utils/with-prod-app.ts
@@ -1,81 +1,81 @@
import _locreq from "locreq";
import { v4 as uuid } from "uuid";
import { module_dirname } from "../utils/module_dirname.js";
const locreq = _locreq(module_dirname(import.meta.url));
import { SMTPMailer } from "sealious";
import { TestUtils } from "sealious";
import TheApp from "../app.js";
import { mainRouter } from "../routes/index.js";
import getPort from "get-port";
import {
MAILCATCHER_API_PORT,
MAILCATCHER_HOST,
MAILCATCHER_SMTP_PORT,
} from "../config.js";
const port_numbers = async function* () {
yield await getPort();
};
export async function withProdApp(
callback: (args: {
app: TheApp;
base_url: string;
rest_api: TestUtils.MockRestApi;
mail_api: TestUtils.MailcatcherAPI;
}) => Promise<void>
) {
const app = new TheApp();
const port = (await port_numbers().next()).value;
if (!port) {
console.error("Constant port is empty.");
return;
}
app.config["www-server"].port = port;
app.config.datastore_mongo = {
...app.config.datastore_mongo,
db_name: "sealious-app-test" + uuid(),
};
app.config.logger.level = <const>"none";
app.mailer = new SMTPMailer({
- host: "127.0.0.1",
+ host: MAILCATCHER_HOST,
port: MAILCATCHER_SMTP_PORT,
user: "any",
password: "any",
});
mainRouter(app.HTTPServer.router);
app.HTTPServer.addStaticRoute("/", locreq.resolve("public"));
await app.start();
const base_url = `http://127.0.0.1:${port}`;
const mail_api = new TestUtils.MailcatcherAPI(
`http://${MAILCATCHER_HOST}:${MAILCATCHER_API_PORT}`,
app
);
await mail_api.deleteAllInstanceEmails();
async function stop() {
await app.removeAllData();
await app.stop();
}
try {
await callback({
app,
base_url,
rest_api: new TestUtils.MockRestApi(base_url),
mail_api,
});
await stop();
} catch (e) {
if (app.status !== "stopped") {
await stop();
}
console.error(e);
throw e;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 8, 10:14 (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1034448
Default Alt Text
(2 KB)
Attached To
Mode
rPLAY Sealious playground
Attached
Detach File
Event Timeline
Log In to Comment