luby/crates/lb/tests/fs.lua
2025-06-27 03:53:08 +10:00

18 lines
460 B
Lua

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)