forked from sofn-xyz/mailing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestUtilIntegration.ts
More file actions
31 lines (23 loc) · 906 Bytes
/
testUtilIntegration.ts
File metadata and controls
31 lines (23 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import chalk from "chalk";
import cliPrisma from "./packages/cli/prisma";
import webPrisma from "./packages/web/prisma";
// logging
const { DEBUG } = process.env;
const PREFIX = "mailing tests";
export function error(message?: any, ...optionalParams: any[]) {
console.error(chalk.red(PREFIX), message, ...optionalParams);
}
export function debug(message?: any, ...optionalParams: any[]) {
if (DEBUG)
console.info(chalk.yellowBright(PREFIX), message, ...optionalParams);
}
export async function truncateCliDatabase() {
debug("Running TRUNCATE on ", process.env.MAILING_DATABASE_URL_TEST);
await cliPrisma.apiKey.deleteMany({});
await cliPrisma.user.deleteMany({});
await cliPrisma.organization.deleteMany({});
}
export async function truncateWebDatabase() {
debug("Running TRUNCATE on ", process.env.WEB_DATABASE_URL_TEST);
await webPrisma.newsletterSubscriber.deleteMany({});
}