Skip to content

Commit e4e8196

Browse files
authored
test: projectionist tests (#108)
1 parent 66539a3 commit e4e8196

File tree

6 files changed

+116
-7
lines changed

6 files changed

+116
-7
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Tests
22

33
on: [push, pull_request]
4+
concurrency:
5+
group: ci-${{ github.ref }}
6+
cancel-in-progress: true
47

58
jobs:
69
unit_tests:
@@ -63,11 +66,14 @@ jobs:
6366
mkdir -p _neovim
6467
curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
6568
}
66-
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
67-
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
68-
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
69+
# mkdir -p ~/.local/share/nvim/site/pack/vendor/start
70+
# git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
71+
# git clone --depth 1 https://github.com/tpope/vim-projectionist ~/.local/share/nvim/site/pack/vendor/start/vim-projectionist
72+
# ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start
6973
7074
- name: Run tests
75+
env:
76+
BUSTED_TIMEOUT: 600000
7177
run: |
7278
export PATH="${PWD}/_neovim/bin:${PATH}"
7379
export VIM="${PWD}/_neovim/share/nvim/runtime"

bin/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
nvim --headless --noplugin -u support/minimal_init.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'support/minimal_init.vim', timeout = 300000}"
3+
NVIM_APPNAME=elixirtoolsplenary nvim --headless -u support/minimal_init.lua -c "PlenaryBustedDirectory ${1:-tests} {init = 'support/minimal_init.lua', timeout = ${BUSTED_TIMEOUT:-180000}}"

bin/test-local

Lines changed: 0 additions & 3 deletions
This file was deleted.

support/minimal_init.lua

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
2+
if not vim.loop.fs_stat(lazypath) then
3+
vim.fn.system {
4+
"git",
5+
"clone",
6+
"--filter=blob:none",
7+
"https://github.com/folke/lazy.nvim.git",
8+
"--branch=stable", -- latest stable release
9+
lazypath,
10+
}
11+
end
12+
vim.opt.rtp:prepend(lazypath)
13+
14+
require("lazy").setup({
15+
{ "elixir-tools/elixir-tools.nvim", dir = vim.loop.cwd() },
16+
{ "nvim-lua/plenary.nvim" },
17+
{ "tpope/vim-projectionist" },
18+
}, {
19+
concurrency = 30,
20+
install = {
21+
missing = true,
22+
},
23+
performance = {
24+
rtp = {
25+
disabled_plugins = {
26+
"gzip",
27+
"matchit",
28+
"matchparen",
29+
"netrwPlugin",
30+
"tarPlugin",
31+
"tohtml",
32+
"tutor",
33+
"zipPlugin",
34+
},
35+
},
36+
},
37+
})

support/minimal_init.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set rtp+=.
22
runtime plugin/plenary.vim
3+
runtime plugin/projectionist.vim

tests/projectionist_spec.lua

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
describe("projectionist", function()
2+
before_each(function()
3+
local tmp_dir = [[./tmp/fixtures]]
4+
vim.fn.system([[rm -rf ]] .. tmp_dir)
5+
vim.fn.system([[mkdir -p ]] .. tmp_dir)
6+
vim.fn.system([[cp -R tests/fixtures/. ]] .. tmp_dir)
7+
vim.cmd.cd(tmp_dir .. "/project_a")
8+
require("elixir.projectionist").setup()
9+
vim.cmd.edit("project_a/lib/module.ex")
10+
end)
11+
12+
after_each(function()
13+
vim.cmd.cd("../../../")
14+
end)
15+
16+
it("Eview", function()
17+
vim.cmd.Eview("project_a_web/user")
18+
vim.cmd.write()
19+
20+
assert.are.same(
21+
vim.fn.readfile("lib/project_a_web/views/user_view.ex"),
22+
{ "defmodule ProjectAWeb.UserView do", " use ProjectAWeb, :view", "end" }
23+
)
24+
end)
25+
26+
it("Econtroller", function()
27+
vim.cmd.Econtroller("project_a_web/user")
28+
vim.cmd.write()
29+
30+
assert.are.same(
31+
vim.fn.readfile("lib/project_a_web/controllers/user_controller.ex"),
32+
{ "defmodule ProjectAWeb.UserController do", " use ProjectAWeb, :controller", "end" }
33+
)
34+
end)
35+
36+
it("Ehtml", function()
37+
vim.cmd.Ehtml("project_a_web/user")
38+
vim.cmd.write()
39+
40+
assert.are.same(vim.fn.readfile("lib/project_a_web/controllers/user_html.ex"), {
41+
"defmodule ProjectAWeb.UserHTML do",
42+
" use ProjectAWeb, :html",
43+
"",
44+
[[ embed_templates "user_html/*"]],
45+
"end",
46+
})
47+
end)
48+
49+
it("Ecomponent", function()
50+
vim.cmd.Ecomponent("project_a_web/user")
51+
vim.cmd.write()
52+
53+
assert.are.same(
54+
vim.fn.readfile("lib/project_a_web/components/user.ex"),
55+
{ "defmodule ProjectAWeb.User do", " use Phoenix.Component", "end" }
56+
)
57+
end)
58+
59+
it("Eliveview", function()
60+
vim.cmd.Eliveview("project_a_web/user")
61+
vim.cmd.write()
62+
63+
assert.are.same(
64+
vim.fn.readfile("lib/project_a_web/live/user_live.ex"),
65+
{ "defmodule ProjectAWeb.UserLive do", " use ProjectAWeb, :live_view", "end" }
66+
)
67+
end)
68+
end)

0 commit comments

Comments
 (0)