Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change test runner #39

Merged
merged 10 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: tests
on: [push, pull_request]

jobs:
tests:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
nvim --headless -u ./spec/minimal_init.lua -c "PlenaryBustedDirectory spec {minimal_init='./spec/minimal_init.lua', sequential=true}"
10 changes: 10 additions & 0 deletions .luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"diagnostics.globals": [
"describe",
"it",
"before_each",
"after_each",
"before_all",
"after_all"
]
}
11 changes: 0 additions & 11 deletions lua/gopher/_utils/init.lua
Original file line number Diff line number Diff line change
@@ -9,17 +9,6 @@ function utils.is_tbl_empty(t)
return next(t) == nil
end

---@param s string
---@return string
function utils.rtrim(s)
local n = #s
while n > 0 and s:find("^%s", n) do
n = n - 1
end

return s:sub(1, n)
end

---@param msg string
---@param lvl any
function utils.deferred_notify(msg, lvl)
41 changes: 0 additions & 41 deletions spec/gopher_config_spec.lua

This file was deleted.

5 changes: 0 additions & 5 deletions spec/gopher_spec.lua

This file was deleted.

49 changes: 0 additions & 49 deletions spec/gopher_struct_tags_spec.lua

This file was deleted.

19 changes: 0 additions & 19 deletions spec/gopher_utils_spec.lua

This file was deleted.

29 changes: 29 additions & 0 deletions spec/units/config_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe("gopher.config", function()
it(".setup() should provide default when .setup() is not called", function()
local c = require "gopher.config"

assert.are.same(c.commands.go, "go")
assert.are.same(c.commands.gomodifytags, "gomodifytags")
assert.are.same(c.commands.gotests, "gotests")
assert.are.same(c.commands.impl, "impl")
assert.are.same(c.commands.iferr, "iferr")
assert.are.same(c.commands.dlv, "dlv")
end)

it(".setup() should change options on users config", function()
local c = require "gopher.config"
c.setup {
commands = {
go = "go1.420",
gomodifytags = "iDontUseRustBtw",
},
}

assert.are.same(c.commands.go, "go1.420")
assert.are.same(c.commands.gomodifytags, "iDontUseRustBtw")
assert.are.same(c.commands.gotests, "gotests")
assert.are.same(c.commands.impl, "impl")
assert.are.same(c.commands.iferr, "iferr")
assert.are.same(c.commands.dlv, "dlv")
end)
end)
25 changes: 25 additions & 0 deletions spec/units/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe("gopher._utils", function()
local u = require "gopher._utils"

describe(".is_tbl_empty()", function()
it("it is empty", function()
assert.are.same(true, u.is_tbl_empty {})
end)

it("it is not empty", function()
assert.are.same(false, u.is_tbl_empty { first = "1", second = 2 })
end)
end)

describe(".sreq()", function()
it("can require existing module", function()
assert.are.same(require "gopher", u.sreq "gopher")
end)

it("cannot require non-existing module", function()
assert.has.errors(function()
u.sreq "iDontExistBtw"
end)
end)
end)
end)