Load test configs when running tests

This commit is contained in:
Râu Cao 2025-04-21 14:29:49 +04:00
parent 3f9dad8f9a
commit 07f881d543
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 12 additions and 3 deletions

1
.env.test Normal file
View File

@ -0,0 +1 @@
RELAY_URLS=wss://nostr.kosmos.org

View File

@ -3,16 +3,21 @@ import { parse as parseYaml } from "jsr:@std/yaml";
import { checkFileExists } from "./utils.ts";
import { log } from "./log.ts";
const denoEnv = Deno.env.get("DENO_ENV");
const dirname = Deno.cwd();
await load({ envPath: `${dirname}/.env`, export: true });
function envAwarePath(path: string): string {
return denoEnv ? `${path}.${denoEnv}` : path;
}
await load({ envPath: envAwarePath(`${dirname}/.env`), export: true });
let userConfigPath: string = "";
let staticUsers: { [key: string]: string } = {};
const defaultUserConfigPaths = [
"/etc/substr/users.yaml",
`${dirname}/users.yaml`,
envAwarePath("/etc/substr/users.yaml"),
envAwarePath(`${dirname}/users.yaml`),
];
for (const path of defaultUserConfigPaths) {

3
users.yaml.test Normal file
View File

@ -0,0 +1,3 @@
_: b3e1b7c0ef48294bd856203bfd460625de95d3afb894e5f09b14cd1f0e7097cf
accounts: b3e1b7c1660b7db0ecb93ec55c09e67961171a5c4e9e2602f1b47477ea61c50a
raucao: 1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb