Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/tests/unit/dotenv-config.test.ts
6449 views
1
/*
2
* environment.test.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
import { assert, assertEquals } from "testing/asserts";
8
import { unitTest } from "../test.ts";
9
import { quartoConfig } from "../../src/core/quarto.ts";
10
11
const workingDir = Deno.makeTempDirSync();
12
13
unitTest(
14
"dotenv config",
15
async () => {
16
// force reload for the test as otherwise the cached value
17
// loaded from tests/ working dir will be used
18
const dotenvConfig = await quartoConfig.dotenv(true);
19
assert(
20
Object.keys(dotenvConfig).length > 0,
21
"Quarto dotenv config is not loading correctly",
22
);
23
},
24
{
25
setup: () => {
26
// testing working dir config wrongly loaded
27
// https://github.com/quarto-dev/quarto-cli/issues/9262
28
Deno.writeTextFileSync(".env.example", "TEST_VAR=")
29
return Promise.resolve();
30
},
31
cwd: () => {
32
return workingDir;
33
},
34
teardown: () => {
35
try {
36
Deno.removeSync(workingDir, { recursive: true });
37
} catch {
38
}
39
return Promise.resolve();
40
},
41
}
42
);
43
44