From 30a26bcda2106e9fa88608e867b4428369f755c4 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Tue, 23 Jul 2024 19:00:26 +0300 Subject: [PATCH] refactor(tests): start migration to mini.test --- .luarc.json | 1 + nvim.toml | 3 ++ spec/units/config_spec.lua | 29 ----------------- {spec => tests}/fixtures/tags/add_input.go | 0 {spec => tests}/fixtures/tags/add_output.go | 0 {spec => tests}/fixtures/tags/remove_input.go | 0 .../fixtures/tags/remove_output.go | 0 tests/units/test_config.lua | 31 +++++++++++++++++++ 8 files changed, 35 insertions(+), 29 deletions(-) delete mode 100644 spec/units/config_spec.lua rename {spec => tests}/fixtures/tags/add_input.go (100%) rename {spec => tests}/fixtures/tags/add_output.go (100%) rename {spec => tests}/fixtures/tags/remove_input.go (100%) rename {spec => tests}/fixtures/tags/remove_output.go (100%) create mode 100644 tests/units/test_config.lua diff --git a/.luarc.json b/.luarc.json index a0d5712..b31ee84 100644 --- a/.luarc.json +++ b/.luarc.json @@ -1,5 +1,6 @@ { "diagnostics.globals": [ + "MiniTest", "describe", "it", "before_each", diff --git a/nvim.toml b/nvim.toml index fa09a88..6c5d5f3 100644 --- a/nvim.toml +++ b/nvim.toml @@ -1,6 +1,9 @@ [vim] any = true +[MiniTest] +type = "table" + [describe] any = true [[describe.args]] diff --git a/spec/units/config_spec.lua b/spec/units/config_spec.lua deleted file mode 100644 index 1fd91dd..0000000 --- a/spec/units/config_spec.lua +++ /dev/null @@ -1,29 +0,0 @@ -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) diff --git a/spec/fixtures/tags/add_input.go b/tests/fixtures/tags/add_input.go similarity index 100% rename from spec/fixtures/tags/add_input.go rename to tests/fixtures/tags/add_input.go diff --git a/spec/fixtures/tags/add_output.go b/tests/fixtures/tags/add_output.go similarity index 100% rename from spec/fixtures/tags/add_output.go rename to tests/fixtures/tags/add_output.go diff --git a/spec/fixtures/tags/remove_input.go b/tests/fixtures/tags/remove_input.go similarity index 100% rename from spec/fixtures/tags/remove_input.go rename to tests/fixtures/tags/remove_input.go diff --git a/spec/fixtures/tags/remove_output.go b/tests/fixtures/tags/remove_output.go similarity index 100% rename from spec/fixtures/tags/remove_output.go rename to tests/fixtures/tags/remove_output.go diff --git a/tests/units/test_config.lua b/tests/units/test_config.lua new file mode 100644 index 0000000..66bfb4f --- /dev/null +++ b/tests/units/test_config.lua @@ -0,0 +1,31 @@ +local eq = MiniTest.expect.equality + +describe("gopher.config", function() + it(".setup() should provide default when .setup() is not called", function() + local c = require "gopher.config" + + eq(c.commands.go, "go") + eq(c.commands.gomodifytags, "gomodifytags") + eq(c.commands.gotests, "gotests") + eq(c.commands.impl, "impl") + eq(c.commands.iferr, "iferr") + eq(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", + }, + } + + eq(c.commands.go, "go1.420") + eq(c.commands.gomodifytags, "iDontUseRustBtw") + eq(c.commands.gotests, "gotests") + eq(c.commands.impl, "impl") + eq(c.commands.iferr, "iferr") + eq(c.commands.dlv, "dlv") + end) +end)