test(config): refactor tests

This commit is contained in:
Smirnov Oleksandr 2023-07-20 19:55:37 +03:00
parent c608ddbd67
commit 1ce9244c52

View file

@ -1,37 +1,29 @@
describe("gopher.config", function() describe("gopher.config", function()
it(".setup() when gets empty table not edit config", function() it(".setup() should provide default when .setup() is not called", function()
local c = require "gopher.config" local c = require "gopher.config"
c.setup {}
assert.are.same(c.config.commands.go, "go") assert.are.same(c.commands.go, "go")
assert.are.same(c.config.commands.gomodifytags, "gomodifytags") assert.are.same(c.commands.gomodifytags, "gomodifytags")
assert.are.same(c.config.commands.gotests, "gotests") assert.are.same(c.commands.gotests, "gotests")
assert.are.same(c.config.commands.impl, "impl") assert.are.same(c.commands.impl, "impl")
assert.are.same(c.commands.iferr, "iferr")
assert.are.same(c.commands.dlv, "dlv")
end) end)
it(".setup() when get one custom value sets that", function() it(".setup() should change options on users config", function()
local c = require "gopher.config"
c.setup { commands = {
go = "custom_go",
} }
assert.are.same(c.config.commands.go, "custom_go")
end)
it(".setup() when get all custom values sets it", function()
local c = require "gopher.config" local c = require "gopher.config"
c.setup { c.setup {
commands = { commands = {
go = "go1.18", go = "go1.420",
gomodifytags = "user-gomodifytags", gomodifytags = "iDontUseRustBtw",
gotests = "gotests",
impl = "goimpl",
}, },
} }
assert.are.same(c.config.commands.go, "go1.18") assert.are.same(c.commands.go, "go1.420")
assert.are.same(c.config.commands.gomodifytags, "user-gomodifytags") assert.are.same(c.commands.gomodifytags, "iDontUseRustBtw")
assert.are.same(c.config.commands.gotests, "gotests") assert.are.same(c.commands.gotests, "gotests")
assert.are.same(c.config.commands.impl, "goimpl") assert.are.same(c.commands.impl, "impl")
assert.are.same(c.commands.iferr, "iferr")
assert.are.same(c.commands.dlv, "dlv")
end) end)
end) end)