test: create lib function for getting mocked env variables
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { formatCmd } from "node_modules/zx/build/util";
|
||||
import { $, minimist } from "zx";
|
||||
|
||||
import { getTestEnvVariables } from "./libs/test/getTestEnv";
|
||||
|
||||
const args = minimist(process.argv.slice(2));
|
||||
if (!args.dbCommand) {
|
||||
if (!args["dbCommand"]) {
|
||||
throw new Error("dbCommand is required");
|
||||
}
|
||||
|
||||
@@ -18,15 +20,14 @@ const positionalArgs = Object.entries(args)
|
||||
})
|
||||
.concat(args._);
|
||||
|
||||
console.log(formatCmd(args.dbCommand));
|
||||
const dbProcess = $({ quote: (arg) => arg })`${args.dbCommand}`.nothrow();
|
||||
console.log(formatCmd(args["dbCommand"]));
|
||||
const dbProcess = $({ quote: (arg) => arg })`${args["dbCommand"]}`.nothrow();
|
||||
|
||||
$.env = {
|
||||
PATH: process.env.PATH,
|
||||
HOME: process.env.HOME,
|
||||
TURSO_URL: process.env.TURSO_URL ?? "http://127.0.0.1:3001",
|
||||
TURSO_AUTH_TOKEN: process.env.TURSO_AUTH_TOKEN ?? "asd",
|
||||
SHOULD_LOG_ERRORS: process.env.SHOULD_LOG_ERRORS ?? "true",
|
||||
...getTestEnvVariables(),
|
||||
PATH: process.env["PATH"],
|
||||
HOME: process.env["HOME"],
|
||||
SHOULD_LOG_ERRORS: process.env["SHOULD_LOG_ERRORS"] ?? "true",
|
||||
};
|
||||
await $`bun db:migrate`.nothrow();
|
||||
await $({
|
||||
|
||||
Reference in New Issue
Block a user