-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(files): parse dir and file with same name
See #62
- Loading branch information
Showing
2 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
local files = require("neotest.lib").files | ||
A = function(...) | ||
print(vim.inspect(...)) | ||
end | ||
|
||
describe("files library", function() | ||
describe("parsing directory tree from files", function() | ||
it("places files under the root", function() | ||
local root = "/root" | ||
local result = files.parse_dir_from_files(root, { "/root/test_a", "/root/test_b" }) | ||
assert.same(result:to_list(), { | ||
{ | ||
id = "/root", | ||
name = "root", | ||
path = "/root", | ||
type = "dir", | ||
}, | ||
{ | ||
{ | ||
id = "/root/test_a", | ||
name = "test_a", | ||
path = "/root/test_a", | ||
type = "file", | ||
}, | ||
}, | ||
{ | ||
{ | ||
id = "/root/test_b", | ||
name = "test_b", | ||
path = "/root/test_b", | ||
type = "file", | ||
}, | ||
}, | ||
}) | ||
end) | ||
|
||
it("places files under the parent directory", function() | ||
local root = "/root" | ||
local result = files.parse_dir_from_files(root, { "/root/dir/test_a", "/root/test_b" }) | ||
assert.same(result:to_list(), { | ||
{ | ||
id = "/root", | ||
name = "root", | ||
path = "/root", | ||
type = "dir", | ||
}, | ||
{ | ||
{ | ||
id = "/root/dir", | ||
name = "dir", | ||
path = "/root/dir", | ||
type = "dir", | ||
}, | ||
{ | ||
{ | ||
id = "/root/dir/test_a", | ||
name = "test_a", | ||
path = "/root/dir/test_a", | ||
type = "file", | ||
}, | ||
}, | ||
}, | ||
{ | ||
{ | ||
id = "/root/test_b", | ||
name = "test_b", | ||
path = "/root/test_b", | ||
type = "file", | ||
}, | ||
}, | ||
}) | ||
end) | ||
|
||
it("parses directory and file with same name", function() | ||
local root = "/root" | ||
local result = | ||
files.parse_dir_from_files(root, { "/root/dir.py", "/root/dir/test_a", "/root/test_b" }) | ||
assert.same(result:to_list(), { | ||
{ | ||
id = "/root", | ||
name = "root", | ||
path = "/root", | ||
type = "dir", | ||
}, | ||
{ | ||
{ | ||
id = "/root/dir", | ||
name = "dir", | ||
path = "/root/dir", | ||
type = "dir", | ||
}, | ||
{ | ||
{ | ||
id = "/root/dir/test_a", | ||
name = "test_a", | ||
path = "/root/dir/test_a", | ||
type = "file", | ||
}, | ||
}, | ||
}, | ||
{ | ||
{ | ||
id = "/root/dir.py", | ||
name = "dir.py", | ||
path = "/root/dir.py", | ||
type = "file", | ||
}, | ||
}, | ||
{ | ||
{ | ||
id = "/root/test_b", | ||
name = "test_b", | ||
path = "/root/test_b", | ||
type = "file", | ||
}, | ||
}, | ||
}) | ||
end) | ||
end) | ||
end) |