Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit e5f3c4c

Browse files
committed
feat: add tests
1 parent eb69c6c commit e5f3c4c

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Used for testing
2+
SIMPLE=ABC
3+
DOUBLE="DEF"
4+
SINGLE="GHI"
5+
6+
OVERWRITE="BAR"

.lune/test.luau

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ end
294294
local function printErr(err: string, traceback: string)
295295
stdio.ewrite(stdio.color("red"))
296296
stdio.ewrite(stdio.style("bold"))
297-
stdio.ewrite(err .. "\n\n")
297+
stdio.ewrite(tostring(err) .. "\n\n")
298298
stdio.ewrite(stdio.style("reset"))
299299
stdio.ewrite(stdio.style("dim"))
300300
stdio.ewrite("[Stack Begin]\n")

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"luau-lsp.require.mode": "relativeToFile",
33
"luau-lsp.require.directoryAliases": {
44
"@lune/": "~/.lune/.typedefs/0.8.4/",
5-
"@testing/": "submodules/util.luau/.lune/test-lib/"
5+
"@testing/": ".lune/test-lib/"
66
}
77
}

tests/envs/path.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CUSTOM_PATH="THIS IS A CUSTOM PATH"

tests/load.test.luau

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
local describe = require("@testing/describe")
2+
local test = require("@testing/test")
3+
local assertEq = require("@testing/assertEq")
4+
local process = require("@lune/process")
5+
6+
local dotenv = require("../lib")
7+
8+
describe("Populate process.env", function()
9+
test("Normal", function()
10+
dotenv:load()
11+
assertEq(process.env.SIMPLE, "ABC")
12+
assertEq(process.env.DOUBLE, "DEF")
13+
assertEq(process.env.SINGLE, "GHI")
14+
end)
15+
16+
test("Overwrite TRUE", function()
17+
process.env.OVERWRITE = "FOO"
18+
dotenv:load(true)
19+
assertEq(process.env.OVERWRITE, "BAR")
20+
end)
21+
22+
test("Overwrite FALSE", function()
23+
process.env.OVERWRITE = "FOO"
24+
dotenv:load(false)
25+
assertEq(process.env.OVERWRITE, "FOO")
26+
end)
27+
28+
test("Custom Path", function()
29+
dotenv:load(false, "tests/envs/path.env")
30+
assertEq(process.env.CUSTOM_PATH, "THIS IS A CUSTOM PATH")
31+
end)
32+
end)

0 commit comments

Comments
 (0)