* feat: support base_dir option for searching for git repos * style: fix indentation * fix: only close file if exists * fix: explicitly set to false if base_dir not set * refactor: always initialize project file * refactor: separate project extraction and project writing * fix: iterate with pairs and no arg for io.lines * refactor: restructure, test, and lint * refactor: use standard telescope file structure * refactor: utilize utility functions for actions module * refactor: support max_depth arg for recursive searching * chore: add Makefile for linting and testing * test: add utils general tests * refactor: do not need file_exists function * test: add tests for creating, writing and reading projects * chore: move location of tests * test: add tests for git project scanning * test: do not need minimal_init.vim now * test: clean up tests * refactor: update git projects on setup
35 lines
1.1 KiB
Lua
35 lines
1.1 KiB
Lua
local path = require("plenary.path")
|
|
|
|
describe("git", function()
|
|
|
|
local git = require("telescope._extensions.project.git")
|
|
local path_to_projects = path:new("/tmp/git_spec_projects")
|
|
local example_project_path = path:new(path_to_projects.filename .. "/example")
|
|
example_project_path:mkdir({ parents = true })
|
|
os.execute("git init --quiet " .. example_project_path.filename)
|
|
|
|
it("try and find path", function()
|
|
vim.fn.execute("cd " .. example_project_path.filename, "silent")
|
|
local git_path = git.try_and_find_git_path()
|
|
assert.equal(example_project_path.filename, git_path)
|
|
end)
|
|
|
|
it("search for repos", function()
|
|
git.tmp_path = "/tmp/found_projects_git_spec.txt"
|
|
git.search_for_git_repos(path_to_projects.filename, 2)
|
|
local git_projects = git.parse_git_repo_paths()
|
|
|
|
local found_git_project = false
|
|
for _, git_project in pairs(git_projects) do
|
|
if git_project.path == example_project_path.filename then
|
|
found_git_project = true
|
|
end
|
|
end
|
|
assert.equal(true, found_git_project)
|
|
end)
|
|
|
|
path:new(git.tmp_path):rm()
|
|
path_to_projects:rm({ recursive = true })
|
|
|
|
end)
|