Path: blob/main/tests/unit/dotenv-config.test.ts
12924 views
/*1* environment.test.ts2*3* Copyright (C) 2020-2022 Posit Software, PBC4*5*/6import { assert, assertEquals } from "testing/asserts";7import { unitTest } from "../test.ts";8import { quartoConfig } from "../../src/core/quarto.ts";910const workingDir = Deno.makeTempDirSync();1112unitTest(13"dotenv config",14async () => {15// force reload for the test as otherwise the cached value16// loaded from tests/ working dir will be used17const dotenvConfig = await quartoConfig.dotenv(true);18assert(19Object.keys(dotenvConfig).length > 0,20"Quarto dotenv config is not loading correctly",21);22},23{24setup: () => {25// testing working dir config wrongly loaded26// https://github.com/quarto-dev/quarto-cli/issues/926227Deno.writeTextFileSync(".env.example", "TEST_VAR=")28return Promise.resolve();29},30cwd: () => {31return workingDir;32},33teardown: () => {34try {35Deno.removeSync(workingDir, { recursive: true });36} catch {37}38return Promise.resolve();39},40}41);424344