Skip to content

Commit d57c1ac

Browse files
committed
test: projectionist tests
1 parent e137208 commit d57c1ac

6 files changed

Lines changed: 120 additions & 7 deletions

File tree

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

0 commit comments

Comments
 (0)