+24
.github/workflows/tests.yml
+24
.github/workflows/tests.yml
···
1
+
name: tests
2
+
on: [push, pull_request]
3
+
4
+
jobs:
5
+
tests:
6
+
strategy:
7
+
matrix:
8
+
os: [ubuntu-latest]
9
+
runs-on: ${{ matrix.os }}
10
+
steps:
11
+
- uses: actions/checkout@v3
12
+
- name: Install Neovim
13
+
shell: bash
14
+
run: |
15
+
mkdir -p /tmp/nvim
16
+
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
17
+
cd /tmp/nvim
18
+
chmod a+x ./nvim.appimage
19
+
./nvim.appimage --appimage-extract
20
+
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
21
+
- name: Run Tests
22
+
run: |
23
+
nvim --version
24
+
nvim --headless -u ./spec/minimal_init.lua -c "PlenaryBustedDirectory spec {minimal_init='./spec/minimal_init.lua', sequential=true}"
+10
.luarc.json
+10
.luarc.json
-11
lua/gopher/_utils/init.lua
-11
lua/gopher/_utils/init.lua
···
9
9
return next(t) == nil
10
10
end
11
11
12
-
---@param s string
13
-
---@return string
14
-
function utils.rtrim(s)
15
-
local n = #s
16
-
while n > 0 and s:find("^%s", n) do
17
-
n = n - 1
18
-
end
19
-
20
-
return s:sub(1, n)
21
-
end
22
-
23
12
---@param msg string
24
13
---@param lvl any
25
14
function utils.deferred_notify(msg, lvl)
-41
spec/gopher_config_spec.lua
-41
spec/gopher_config_spec.lua
···
1
-
describe("gopher.config", function()
2
-
it("can be required", function()
3
-
require "gopher.config"
4
-
end)
5
-
6
-
it(".setup() when gets empty table not edit config", function()
7
-
local c = require "gopher.config"
8
-
c.setup {}
9
-
10
-
assert.are.same(c.config.commands.go, "go")
11
-
assert.are.same(c.config.commands.gomodifytags, "gomodifytags")
12
-
assert.are.same(c.config.commands.gotests, "gotests")
13
-
assert.are.same(c.config.commands.impl, "impl")
14
-
end)
15
-
16
-
it(".setup() when get one custom value sets that", function()
17
-
local c = require "gopher.config"
18
-
c.setup { commands = {
19
-
go = "custom_go",
20
-
} }
21
-
22
-
assert.are.same(c.config.commands.go, "custom_go")
23
-
end)
24
-
25
-
it(".setup() when get all custom values sets it", function()
26
-
local c = require "gopher.config"
27
-
c.setup {
28
-
commands = {
29
-
go = "go1.18",
30
-
gomodifytags = "user-gomodifytags",
31
-
gotests = "gotests",
32
-
impl = "goimpl",
33
-
},
34
-
}
35
-
36
-
assert.are.same(c.config.commands.go, "go1.18")
37
-
assert.are.same(c.config.commands.gomodifytags, "user-gomodifytags")
38
-
assert.are.same(c.config.commands.gotests, "gotests")
39
-
assert.are.same(c.config.commands.impl, "goimpl")
40
-
end)
41
-
end)
-5
spec/gopher_spec.lua
-5
spec/gopher_spec.lua
-19
spec/gopher_utils_spec.lua
-19
spec/gopher_utils_spec.lua
···
1
-
describe("gopher._utils", function()
2
-
it("can be requried", function()
3
-
require "gopher._utils"
4
-
end)
5
-
6
-
it(".empty() with non-empty talbe", function()
7
-
local empty = require("gopher._utils").empty
8
-
local res = empty { first = "1", second = 2 }
9
-
10
-
assert.are.same(res, false)
11
-
end)
12
-
13
-
it(".empty() with empty talbe", function()
14
-
local empty = require("gopher._utils").empty
15
-
local res = empty {}
16
-
17
-
assert.are.same(res, true)
18
-
end)
19
-
end)
+29
spec/units/config_spec.lua
+29
spec/units/config_spec.lua
···
1
+
describe("gopher.config", function()
2
+
it(".setup() should provide default when .setup() is not called", function()
3
+
local c = require "gopher.config"
4
+
5
+
assert.are.same(c.commands.go, "go")
6
+
assert.are.same(c.commands.gomodifytags, "gomodifytags")
7
+
assert.are.same(c.commands.gotests, "gotests")
8
+
assert.are.same(c.commands.impl, "impl")
9
+
assert.are.same(c.commands.iferr, "iferr")
10
+
assert.are.same(c.commands.dlv, "dlv")
11
+
end)
12
+
13
+
it(".setup() should change options on users config", function()
14
+
local c = require "gopher.config"
15
+
c.setup {
16
+
commands = {
17
+
go = "go1.420",
18
+
gomodifytags = "iDontUseRustBtw",
19
+
},
20
+
}
21
+
22
+
assert.are.same(c.commands.go, "go1.420")
23
+
assert.are.same(c.commands.gomodifytags, "iDontUseRustBtw")
24
+
assert.are.same(c.commands.gotests, "gotests")
25
+
assert.are.same(c.commands.impl, "impl")
26
+
assert.are.same(c.commands.iferr, "iferr")
27
+
assert.are.same(c.commands.dlv, "dlv")
28
+
end)
29
+
end)
+25
spec/units/utils_spec.lua
+25
spec/units/utils_spec.lua
···
1
+
describe("gopher._utils", function()
2
+
local u = require "gopher._utils"
3
+
4
+
describe(".is_tbl_empty()", function()
5
+
it("it is empty", function()
6
+
assert.are.same(true, u.is_tbl_empty {})
7
+
end)
8
+
9
+
it("it is not empty", function()
10
+
assert.are.same(false, u.is_tbl_empty { first = "1", second = 2 })
11
+
end)
12
+
end)
13
+
14
+
describe(".sreq()", function()
15
+
it("can require existing module", function()
16
+
assert.are.same(require "gopher", u.sreq "gopher")
17
+
end)
18
+
19
+
it("cannot require non-existing module", function()
20
+
assert.has.errors(function()
21
+
u.sreq "iDontExistBtw"
22
+
end)
23
+
end)
24
+
end)
25
+
end)