Skip to content

Commit 187b5f4

Browse files
committed
test: configure CI
1 parent 0fab8e6 commit 187b5f4

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Run tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
unit_tests:
7+
name: unit tests
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
os: [ubuntu-22.04]
13+
rev: [nightly]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: rhysd/action-setup-vim@v1
19+
with:
20+
neovim: true
21+
version: ${{ matrix.rev }}
22+
23+
- name: Download requirements
24+
run: |
25+
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ../plenary.nvim
26+
27+
- name: Run tests
28+
run: |
29+
nvim --version
30+
make test

.luarc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"diagnostics.globals": [
3+
"it",
4+
"describe"
5+
]
6+
}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: test
2+
3+
test:
4+
nvim --headless --noplugin -u scripts/minimal_init.vim -c "PlenaryBustedDirectory tests/ { minimal_init = './scripts/minimal_init.vim' }"

scripts/minimal_init.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
set rtp+=.
2+
set rtp+=../plenary.nvim/
3+
4+
runtime! plugin/plenary.vim

scripts/skeletons/README/base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Hello World!

scripts/skeletons/lua/base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello World!")

tests/autocmd_spec.lua

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---@diagnostic disable: undefined-global, lowercase-global, undefined-field
2+
3+
local eq = assert.are.same
4+
5+
describe("createautocmd", function()
6+
-- Setup environment for tests
7+
before_each(function()
8+
local opts = {
9+
autouse = true,
10+
directories = { vim.fn.stdpath("config") .. "/skeletons" },
11+
patterns = function(dir) return vim.fn.readdir(dir) end,
12+
wildcards = {
13+
expand = true,
14+
lookup = {
15+
-- File
16+
["filename"] = function() return vim.fn.expand("%:t:r") end,
17+
["fileabspath"] = function() return vim.fn.expand("%:p") end,
18+
["filerelpath"] = function() return vim.fn.expand("%:p:~") end,
19+
["fileext"] = function() return vim.fn.expand("%:e") end,
20+
["filetype"] = function() return vim.bo.filetype end,
21+
22+
-- Date and time
23+
["date"] = function() return os.date("%Y%m%d", os.time()) end,
24+
["year"] = function() return os.date("%Y", os.time()) end,
25+
["month"] = function() return os.date("%m", os.time()) end,
26+
["day"] = function() return os.date("%d", os.time()) end,
27+
["time"] = function() return os.date("%T", os.time()) end,
28+
29+
-- System
30+
["host"] = "gh",
31+
["user"] = "gh-ci",
32+
33+
-- Github
34+
["gh-email"] = "n/a",
35+
["gh-user"] = "n/a",
36+
},
37+
},
38+
advanced = {
39+
ignored = {},
40+
ignore_os_files = true,
41+
},
42+
}
43+
44+
autocmds = require("esqueleto.autocmd").createautocmd(opts)
45+
end)
46+
47+
it("should createa autocmds", function()
48+
-- Expected behaviour
49+
local group_name = "esqueleto"
50+
local existing_autocmds = vim.api.nvim_get_autocmds({
51+
group = group_name,
52+
})
53+
vim.print(existing_autocmds)
54+
55+
-- Observed behaviour
56+
57+
eq(true == true) -- Check if behaviours are equal
58+
end)
59+
end)

0 commit comments

Comments
 (0)