diff options
author | 2023-08-15 18:40:00 -0700 | |
---|---|---|
committer | 2023-08-21 17:49:58 -0700 | |
commit | 4003856575ec566ffbf51221d7782e9bda379d1d (patch) | |
tree | a9efbb903872e6d0dbac99082620eb303b475d90 /test/cli/run/bunfig.test.ts | |
parent | 2bb084e3f3184778556885ba1f3d22a862d57dff (diff) | |
download | bun-4003856575ec566ffbf51221d7782e9bda379d1d.tar.gz bun-4003856575ec566ffbf51221d7782e9bda379d1d.tar.zst bun-4003856575ec566ffbf51221d7782e9bda379d1d.zip |
Add test for absolute paths
Diffstat (limited to 'test/cli/run/bunfig.test.ts')
-rw-r--r-- | test/cli/run/bunfig.test.ts | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/cli/run/bunfig.test.ts b/test/cli/run/bunfig.test.ts index 0c8a23c65..efb4355ac 100644 --- a/test/cli/run/bunfig.test.ts +++ b/test/cli/run/bunfig.test.ts @@ -58,6 +58,17 @@ describe("config", () => { } }); + test("read --config *.json absolute path", () => { + { + const dir = tempDirWithFiles("dotenv", { + "bun2.json": `{"define": { "caterpillar": "'butterfly'" }}`, + "index.ts": "console.log(caterpillar);", + }); + const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/bun2.json`] }); + expect(stdout).toBe("butterfly"); + } + }); + test("read --config *.toml", () => { { const dir = tempDirWithFiles("dotenv", { @@ -68,6 +79,7 @@ describe("config", () => { expect(stdout).toBe("butterfly"); } }); + test("read -c *.toml", () => { { const dir = tempDirWithFiles("dotenv", { @@ -78,4 +90,39 @@ describe("config", () => { expect(stdout).toBe("butterfly"); } }); + + test("read --config absolute path", () => { + { + const dir = tempDirWithFiles("dotenv", { + "bun2.toml": `[define]\n"caterpillar" = "'butterfly'"`, + "index.ts": "console.log(caterpillar);", + }); + const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/bun2.toml`] }); + expect(stdout).toBe("butterfly"); + } + }); + + test("fail if --config absolute path can't be found", () => { + { + const dir = tempDirWithFiles("dotenv", { + "index.ts": "console.log(caterpillar);", + }); + + { + expect(() => { + bunRun(`${dir}/index.ts`, {}, { flags: ["-c", `${dir}/notreal.json`] }); + }).toThrow(); + } + } + }); + // test("read --config absolute path", () => { + // { + // const dir = tempDirWithFiles("dotenv", { + // "bun2.toml": `[define]\n"caterpillar" = "'butterfly'"`, + // "index.ts": "console.log(caterpillar);", + // }); + // const { stdout } = bunRun(`${dir}/index.ts`, {}, { flags: ["-c", "bun2.toml"] }); + // expect(stdout).toBe("butterfly"); + // } + // }); }); |