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

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Eggflaw committed May 28, 2024
1 parent eb69c6c commit e5f3c4c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Used for testing
SIMPLE=ABC
DOUBLE="DEF"
SINGLE="GHI"

OVERWRITE="BAR"
2 changes: 1 addition & 1 deletion .lune/test.luau
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ end
local function printErr(err: string, traceback: string)
stdio.ewrite(stdio.color("red"))
stdio.ewrite(stdio.style("bold"))
stdio.ewrite(err .. "\n\n")
stdio.ewrite(tostring(err) .. "\n\n")
stdio.ewrite(stdio.style("reset"))
stdio.ewrite(stdio.style("dim"))
stdio.ewrite("[Stack Begin]\n")
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"luau-lsp.require.mode": "relativeToFile",
"luau-lsp.require.directoryAliases": {
"@lune/": "~/.lune/.typedefs/0.8.4/",
"@testing/": "submodules/util.luau/.lune/test-lib/"
"@testing/": ".lune/test-lib/"
}
}
1 change: 1 addition & 0 deletions tests/envs/path.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CUSTOM_PATH="THIS IS A CUSTOM PATH"
32 changes: 32 additions & 0 deletions tests/load.test.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local describe = require("@testing/describe")
local test = require("@testing/test")
local assertEq = require("@testing/assertEq")
local process = require("@lune/process")

local dotenv = require("../lib")

describe("Populate process.env", function()
test("Normal", function()
dotenv:load()
assertEq(process.env.SIMPLE, "ABC")
assertEq(process.env.DOUBLE, "DEF")
assertEq(process.env.SINGLE, "GHI")
end)

test("Overwrite TRUE", function()
process.env.OVERWRITE = "FOO"
dotenv:load(true)
assertEq(process.env.OVERWRITE, "BAR")
end)

test("Overwrite FALSE", function()
process.env.OVERWRITE = "FOO"
dotenv:load(false)
assertEq(process.env.OVERWRITE, "FOO")
end)

test("Custom Path", function()
dotenv:load(false, "tests/envs/path.env")
assertEq(process.env.CUSTOM_PATH, "THIS IS A CUSTOM PATH")
end)
end)

0 comments on commit e5f3c4c

Please sign in to comment.