Add tempdir support
This commit is contained in:
17
crates/lb/tests/fs.lua
Normal file
17
crates/lb/tests/fs.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
local ok, fs = pcall(require, "lb:fs")
|
||||
if not ok then return end
|
||||
|
||||
describe("temp files", function()
|
||||
test("temp_dir cleans itself", function()
|
||||
local path
|
||||
do
|
||||
local dir = fs:temp_dir()
|
||||
path = dir:path()
|
||||
assert(path and path ~= "")
|
||||
fs:write(path .. "/test.txt", "test file")
|
||||
assert(fs:read(path .. "/test.txt") == "test file")
|
||||
end
|
||||
collectgarbage()
|
||||
assert(not pcall(fs.read, fs, path .. "/test.txt"))
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user