Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ jobs:
nvim --version
nvim --headless -c "checkhealth swift" -c "quit" || true

- name: Run Unit Tests
run: |
nvim --headless -u tests/minimal_init.lua -c "PlenaryBustedDirectory tests/ { minimal_init = 'tests/minimal_init.lua' }"

labeler:
name: Auto Label
runs-on: ubuntu-latest
Expand Down
19 changes: 19 additions & 0 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local root = vim.fn.fnamemodify("./.tests", ":p")

-- set stdpaths to use .tests
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[string.format("XDG_%s_HOME", name:upper())] = root .. "/" .. name
end

local function load_plugin(plugin_repo)
local name = plugin_repo:match(".*/(.*)%.git") or plugin_repo:match(".*/(.*)")
local plugin_path = root .. "/plugins/" .. name
if vim.fn.isdirectory(plugin_path) == 0 then
vim.fn.system({ "git", "clone", "--depth=1", "https://github.com/" .. plugin_repo, plugin_path })
end
vim.opt.runtimepath:prepend(plugin_path)
end

load_plugin("nvim-lua/plenary.nvim")

vim.opt.runtimepath:prepend(".")
23 changes: 23 additions & 0 deletions tests/swift/project_detector_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local detector = require("swift.features.project_detector")

describe("Project Detector", function()
it("should be able to require the module", function()
assert.is_not_nil(detector)
end)

it("should return none when no project files are found", function()
local temp_dir = vim.fn.tempname()
vim.fn.mkdir(temp_dir, "p")

local old_cwd = vim.fn.getcwd()
vim.api.nvim_set_current_dir(temp_dir)

-- Force refresh cache
local info = detector.get_project_info(true)

assert.are.same("none", info.type)

vim.api.nvim_set_current_dir(old_cwd)
vim.fn.delete(temp_dir, "rf")
end)
end)
Loading