lune/tests/fs/dirs.luau

28 lines
1,019 B
Text
Raw Normal View History

2023-07-20 19:06:42 +01:00
local TEMP_DIR_PATH = "bin/"
local TEMP_ROOT_PATH = TEMP_DIR_PATH .. "fs_dirs_test"
local fs = require("@lune/fs")
2023-07-20 19:06:42 +01:00
-- Write two inner dirs in the bin dir, a parent and a child
2023-01-21 07:01:46 +00:00
2023-07-20 19:06:42 +01:00
fs.writeDir(TEMP_ROOT_PATH .. "/test_inner")
2023-01-21 07:01:46 +00:00
-- Make sure dir checks succeed but file
-- checks fail for all levels of dirs
2023-07-20 19:06:42 +01:00
assert(fs.isDir(TEMP_DIR_PATH), "Dir root isDir check failed")
assert(fs.isDir(TEMP_ROOT_PATH), "Dir outer isDir check failed")
assert(fs.isDir(TEMP_ROOT_PATH .. "/test_inner"), "Dir inner isDir check failed")
2023-01-21 07:01:46 +00:00
2023-07-20 19:06:42 +01:00
assert(not fs.isFile(TEMP_DIR_PATH), "Dir root isFile check failed")
assert(not fs.isFile(TEMP_ROOT_PATH), "Dir outer isFile check failed")
assert(not fs.isFile(TEMP_ROOT_PATH .. "/test_inner"), "Dir inner isFile check failed")
2023-01-21 07:01:46 +00:00
-- Remove the created parent and child dirs and
-- make sure the APIs say they no longer exist
2023-07-20 19:06:42 +01:00
fs.removeDir(TEMP_ROOT_PATH)
2023-01-21 07:01:46 +00:00
2023-07-20 19:06:42 +01:00
assert(not fs.isDir(TEMP_ROOT_PATH), "After removal isDir check failed")
assert(not fs.isFile(TEMP_ROOT_PATH), "After removal isFile check failed")