Skip to content

Commit 0fc6da4

Browse files
authored
Merge pull request #14 from tomgeorge/test-library
feat: Add a basic testing setup.
2 parents 544d21b + 0254e1d commit 0fc6da4

File tree

5 files changed

+101
-0
lines changed

5 files changed

+101
-0
lines changed

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
neovim_version: ['v0.9.5', 'v0.10.0', 'nightly']
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install Neovim
20+
uses: rhymond/setup-neovim@v1
21+
with:
22+
neovim-version: ${{ matrix.neovim_version }}
23+
24+
- name: Run tests
25+
run: make test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deps/

Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Makefile for ECA Neovim plugin testing
2+
3+
.PHONY: test test-file deps clean
4+
5+
# Download dependencies for testing
6+
deps: deps/mini.nvim deps/nui.nvim
7+
8+
deps/mini.nvim:
9+
mkdir -p deps
10+
git clone --filter=blob:none https://github.com/echasnovski/mini.nvim deps/mini.nvim
11+
12+
deps/nui.nvim:
13+
mkdir -p deps
14+
git clone --filter=blob:none https://github.com/MunifTanjim/nui.nvim deps/nui.nvim
15+
16+
# Run all tests
17+
test: deps
18+
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()"
19+
20+
# Run a specific test file
21+
# Usage: make test-file FILE=tests/test_example.lua
22+
test-file: deps
23+
nvim --headless --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run_file('$(FILE)')"
24+
25+
# Clean up dependencies
26+
clean:
27+
rm -rf deps/

scripts/minimal_init.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Minimal init.lua for testing
2+
vim.cmd([[let &rtp.=','.getcwd()]])
3+
4+
-- Add dependencies to runtime path if headless
5+
if #vim.api.nvim_list_uis() == 0 then
6+
vim.cmd('set rtp+=deps/mini.nvim')
7+
vim.cmd('set rtp+=deps/nui.nvim')
8+
require('mini.test').setup({
9+
collect = {
10+
emulate_busted = true,
11+
find_files = function()
12+
return vim.fn.globpath('tests', '**/test_*.lua', true, true)
13+
end,
14+
},
15+
execute = {
16+
stop_on_error = false,
17+
},
18+
silent = false,
19+
})
20+
end

tests/test_eca.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
local MiniTest = require("mini.test")
2+
local T = MiniTest.new_set()
3+
4+
-- Test that the plugin loads without errors
5+
T["loads without error"] = function()
6+
MiniTest.expect.no_error(function()
7+
require("eca")
8+
end)
9+
end
10+
11+
-- Test basic config functionality
12+
T["config"] = MiniTest.new_set()
13+
14+
T["config"]["has default values"] = function()
15+
local config = require("eca.config")
16+
MiniTest.expect.equality(type(config), "table")
17+
end
18+
19+
-- Test utilities
20+
T["utils"] = MiniTest.new_set()
21+
22+
T["utils"]["module exists"] = function()
23+
MiniTest.expect.no_error(function()
24+
require("eca.utils")
25+
end)
26+
end
27+
28+
return T

0 commit comments

Comments
 (0)