From 4f56745de6a88b8a0e577c6353fc2a7246b2e4f3 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Fri, 12 Jul 2024 09:12:12 +0200 Subject: [PATCH] refactor: layout (#117) --- README.md | 29 +++++++++-------- .../features/testify/lookup.lua | 4 +-- .../features/testify/tree_modification.lua | 6 ++-- lua/neotest-golang/init.lua | 31 +++++++++---------- lua/neotest-golang/{ => lib}/cmd.lua | 2 +- lua/neotest-golang/{ => lib}/convert.lua | 0 lua/neotest-golang/{ => lib}/find.lua | 0 lua/neotest-golang/lib/init.lua | 8 +++++ lua/neotest-golang/{ => lib}/json.lua | 0 lua/neotest-golang/{parse.lua => process.lua} | 9 +++--- lua/neotest-golang/{ast.lua => query.lua} | 0 .../{runspec_dir.lua => runspec/dir.lua} | 9 +++--- .../{runspec_file.lua => runspec/file.lua} | 14 ++++----- lua/neotest-golang/runspec/init.lua | 10 ++++++ .../namespace.lua} | 11 +++---- .../{runspec_test.lua => runspec/test.lua} | 11 +++---- tests/go/testname_spec.lua | 14 ++++----- tests/unit/is_test_file_spec.lua | 1 + tests/unit/json_spec.lua | 11 ++++--- tests/unit/options_spec.lua | 1 + 20 files changed, 92 insertions(+), 79 deletions(-) rename lua/neotest-golang/{ => lib}/cmd.lua (98%) rename lua/neotest-golang/{ => lib}/convert.lua (100%) rename lua/neotest-golang/{ => lib}/find.lua (100%) create mode 100644 lua/neotest-golang/lib/init.lua rename lua/neotest-golang/{ => lib}/json.lua (100%) rename lua/neotest-golang/{parse.lua => process.lua} (97%) rename lua/neotest-golang/{ast.lua => query.lua} (100%) rename lua/neotest-golang/{runspec_dir.lua => runspec/dir.lua} (87%) rename lua/neotest-golang/{runspec_file.lua => runspec/file.lua} (84%) create mode 100644 lua/neotest-golang/runspec/init.lua rename lua/neotest-golang/{runspec_namespace.lua => runspec/namespace.lua} (69%) rename lua/neotest-golang/{runspec_test.lua => runspec/test.lua} (78%) diff --git a/README.md b/README.md index 3dc34f47..ae771ebf 100644 --- a/README.md +++ b/README.md @@ -73,14 +73,14 @@ return { ## ⚙️ Configuration -| Argument | Default value | Description | -| ------------------------ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `go_test_args` | `{ "-v", "-race", "-count=1" }` | Arguments to pass into `go test`. | -| `dap_go_enabled` | `false` | Leverage [leoluz/nvim-dap-go](https://github.com/leoluz/nvim-dap-go) for debugging tests. | -| `dap_go_opts` | `{}` | Options to pass into `require("dap-go").setup()`. | +| Argument | Default value | Description | +| ------------------------ | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `go_test_args` | `{ "-v", "-race", "-count=1" }` | Arguments to pass into `go test`. | +| `dap_go_enabled` | `false` | Leverage [leoluz/nvim-dap-go](https://github.com/leoluz/nvim-dap-go) for debugging tests. | +| `dap_go_opts` | `{}` | Options to pass into `require("dap-go").setup()`. | | `testify_enabled` | `false` | Enable support for [testify](https://github.com/stretchr/testify) suites. See [here](https://github.com/fredrikaverpil/neotest-golang#testify-suites) for more info. | -| `warn_test_name_dupes` | `true` | Warn about duplicate test names within the same Go package. | -| `warn_test_not_executed` | `true` | Warn if test was not executed. | +| `warn_test_name_dupes` | `true` | Warn about duplicate test names within the same Go package. | +| `warn_test_not_executed` | `true` | Warn if test was not executed. | ### Example configuration: custom `go test` arguments @@ -359,10 +359,8 @@ more information on this. ### Testify suites -> [!WARNING] -> This feature comes with some caveats and nuances, which is why it -> is not enabled by default. I advise you to only enable this if -> you need it. +> [!WARNING] This feature comes with some caveats and nuances, which is why it +> is not enabled by default. I advise you to only enable this if you need it. There are some real shenaningans going on behind the scenes to make this work. 😅 First, a lookup of "receiver type-to-suite test function" will be created of @@ -371,8 +369,7 @@ modified by mutating private attributes and merging of nodes to avoid duplicates. I'm personally a bit afraid of the maintenance burden of this feature... 🙈 -> [!NOTE] -> Right now, there is no way to update the lookup other than restarting +> [!NOTE] Right now, there is no way to update the lookup other than restarting > Neotest/Neovim. So in case you are implementing a new suite, please restart to > see the new suites/tests appear in e.g. the summary window. Also, nested tests > or table tests are not supported. All of this can be remedied at any time. @@ -406,5 +403,7 @@ looks like for the Go test file. Again, from the Go test file, execute `:EditQuery` to open up the query editor in a separate window. In the editor, you can now start creating your syntax -query and play around. You can paste in queries from `ast.lua` in the editor, to -see how the query behaves and highlights parts of your Go test file. +query and play around. You can paste in queries from +[`query.lua`](https://github.com/fredrikaverpil/neotest-golang/blob/main/lua/neotest-golang/query.lua) +in the editor, to see how the query behaves and highlights parts of your Go test +file. diff --git a/lua/neotest-golang/features/testify/lookup.lua b/lua/neotest-golang/features/testify/lookup.lua index f06c8ba2..06aaa0b8 100644 --- a/lua/neotest-golang/features/testify/lookup.lua +++ b/lua/neotest-golang/features/testify/lookup.lua @@ -1,6 +1,6 @@ --- Lookup table for renaming Neotest namespaces (receiver type to testify suite function). -local find = require("neotest-golang.find") +local lib = require("neotest-golang.lib") local query = require("neotest-golang.features.testify.query") local M = {} @@ -80,7 +80,7 @@ end --- @return table The generated lookup table function M.generate() local cwd = vim.fn.getcwd() - local filepaths = find.go_test_filepaths(cwd) + local filepaths = lib.find.go_test_filepaths(cwd) local lookup = {} -- local global_suites = {} diff --git a/lua/neotest-golang/features/testify/tree_modification.lua b/lua/neotest-golang/features/testify/tree_modification.lua index 6864e509..8e5832fc 100644 --- a/lua/neotest-golang/features/testify/tree_modification.lua +++ b/lua/neotest-golang/features/testify/tree_modification.lua @@ -41,7 +41,8 @@ function M.replace_receiver_with_suite(tree, lookup_table) -- TODO: To make this more robust, it would be a good idea to only perform replacements -- within the relevant Go package. Right now, this implementation is naive and will - -- not check for package boundaries. The file lookup contains all data required for this. + -- not check for package boundaries. Replacement are done "globally", replacing 'a' with + -- 'b' everywhere, across all test files. local replacements = {} local suite_functions = {} for _, file_data in pairs(lookup_table) do @@ -126,7 +127,8 @@ end function M.update_node(n, replacements, suite_functions) -- TODO: To make this more robust, it would be a good idea to only perform replacements -- within the relevant Go package. Right now, this implementation is naive and will - -- not check for package boundaries. + -- not check for package boundaries. Replacement are done "globally", replacing 'a' with + -- 'b' everywhere, across all test files. for receiver, suite in pairs(replacements) do if n._data.name == receiver then n._data.name = suite diff --git a/lua/neotest-golang/init.lua b/lua/neotest-golang/init.lua index 912616f8..bc1bf9d1 100644 --- a/lua/neotest-golang/init.lua +++ b/lua/neotest-golang/init.lua @@ -2,12 +2,9 @@ --- Neotest interface: https://github.com/nvim-neotest/neotest/blob/master/lua/neotest/adapters/interface.lua local options = require("neotest-golang.options") -local ast = require("neotest-golang.ast") -local runspec_dir = require("neotest-golang.runspec_dir") -local runspec_file = require("neotest-golang.runspec_file") -local runspec_namespace = require("neotest-golang.runspec_namespace") -local runspec_test = require("neotest-golang.runspec_test") -local parse = require("neotest-golang.parse") +local query = require("neotest-golang.query") +local runspec = require("neotest-golang.runspec") +local process = require("neotest-golang.process") local testify = require("neotest-golang.features.testify") local M = {} @@ -63,7 +60,7 @@ end --- @param file_path string Absolute file path --- @return neotest.Tree | nil function M.Adapter.discover_positions(file_path) - return ast.detect_tests(file_path) + return query.detect_tests(file_path) end --- Build the runspec, which describes what command(s) are to be executed. @@ -111,23 +108,23 @@ function M.Adapter.build_spec(args) -- A runspec is to be created, based on running all tests in the given -- directory. In this case, the directory is also the current working -- directory. - return runspec_dir.build(pos) + return runspec.dir.build(pos) elseif pos.type == "dir" then -- A runspec is to be created, based on running all tests in the given -- directory. In this case, the directory is a sub-directory of the current -- working directory. - return runspec_dir.build(pos) + return runspec.dir.build(pos) elseif pos.type == "file" then -- A runspec is to be created, based on on running all tests in the given -- file. - return runspec_file.build(pos, tree) + return runspec.file.build(pos, tree) elseif pos.type == "namespace" then -- A runspec is to be created, based on running all tests in the given -- namespace. - return runspec_namespace.build(pos) + return runspec.namespace.build(pos) elseif pos.type == "test" then -- A runspec is to be created, based on on running the given test. - return runspec_test.build(pos, args.strategy) + return runspec.test.build(pos, args.strategy) end vim.notify( @@ -149,25 +146,25 @@ function M.Adapter.results(spec, result, tree) if spec.context.pos_type == "dir" then -- A test command executed a directory of tests and the output/status must -- now be processed. - local results = parse.test_results(spec, result, tree) + local results = process.test_results(spec, result, tree) M.workaround_neotest_issue_391(result) return results elseif spec.context.pos_type == "file" then -- A test command executed a file of tests and the output/status must -- now be processed. - local results = parse.test_results(spec, result, tree) + local results = process.test_results(spec, result, tree) M.workaround_neotest_issue_391(result) return results elseif spec.context.pos_type == "namespace" then -- A test command executed a namespace and the output/status must now be -- processed. - local results = parse.test_results(spec, result, tree) + local results = process.test_results(spec, result, tree) M.workaround_neotest_issue_391(result) return results elseif spec.context.pos_type == "test" then -- A test command executed a single test and the output/status must now be -- processed. - local results = parse.test_results(spec, result, tree) + local results = process.test_results(spec, result, tree) M.workaround_neotest_issue_391(result) return results end @@ -182,7 +179,7 @@ end --- Workaround, to avoid JSON in output panel, erase contents of output. --- @param result neotest.StrategyResult function M.workaround_neotest_issue_391(result) - -- FIXME: once output is parsed, erase file contents, so to avoid JSON in + -- FIXME: once output is processed, erase file contents, so to avoid JSON in -- output panel. This is a workaround for now, only because of -- https://github.com/nvim-neotest/neotest/issues/391 diff --git a/lua/neotest-golang/cmd.lua b/lua/neotest-golang/lib/cmd.lua similarity index 98% rename from lua/neotest-golang/cmd.lua rename to lua/neotest-golang/lib/cmd.lua index 2839f3da..cde3aadd 100644 --- a/lua/neotest-golang/cmd.lua +++ b/lua/neotest-golang/lib/cmd.lua @@ -3,7 +3,7 @@ local async = require("neotest.async") local options = require("neotest-golang.options") -local json = require("neotest-golang.json") +local json = require("neotest-golang.lib.json") local M = {} diff --git a/lua/neotest-golang/convert.lua b/lua/neotest-golang/lib/convert.lua similarity index 100% rename from lua/neotest-golang/convert.lua rename to lua/neotest-golang/lib/convert.lua diff --git a/lua/neotest-golang/find.lua b/lua/neotest-golang/lib/find.lua similarity index 100% rename from lua/neotest-golang/find.lua rename to lua/neotest-golang/lib/find.lua diff --git a/lua/neotest-golang/lib/init.lua b/lua/neotest-golang/lib/init.lua new file mode 100644 index 00000000..7ffb8f4f --- /dev/null +++ b/lua/neotest-golang/lib/init.lua @@ -0,0 +1,8 @@ +local M = {} + +M.convert = require("neotest-golang.lib.convert") +M.cmd = require("neotest-golang.lib.cmd") +M.find = require("neotest-golang.lib.find") +M.json = require("neotest-golang.lib.json") + +return M diff --git a/lua/neotest-golang/json.lua b/lua/neotest-golang/lib/json.lua similarity index 100% rename from lua/neotest-golang/json.lua rename to lua/neotest-golang/lib/json.lua diff --git a/lua/neotest-golang/parse.lua b/lua/neotest-golang/process.lua similarity index 97% rename from lua/neotest-golang/parse.lua rename to lua/neotest-golang/process.lua index 424e5dfc..2b237b0c 100644 --- a/lua/neotest-golang/parse.lua +++ b/lua/neotest-golang/process.lua @@ -4,8 +4,7 @@ local async = require("neotest.async") local options = require("neotest-golang.options") -local convert = require("neotest-golang.convert") -local json = require("neotest-golang.json") +local lib = require("neotest-golang.lib") -- TODO: remove pos_type when properly supporting all position types. -- and instead get this from the pos.type field. @@ -80,7 +79,7 @@ function M.test_results(spec, result, tree) raw_output = async.fn.readfile(context.test_output_json_filepath) end - local gotest_output = json.process_gotest_json_output(raw_output) + local gotest_output = lib.json.process_gotest_json_output(raw_output) --- The 'go list -json' output, converted into a lua table. local golist_output = context.golist_data @@ -223,9 +222,9 @@ function M.decorate_with_go_package_and_test_name( for _, gotestline in ipairs(gotest_output) do if gotestline.Action == "run" and gotestline.Test ~= nil then if gotestline.Package == golistline.ImportPath then - local pattern = convert.to_lua_pattern(folderpath) + local pattern = lib.convert.to_lua_pattern(folderpath) .. "/(.-)/" - .. convert.to_lua_pattern(gotestline.Test) + .. lib.convert.to_lua_pattern(gotestline.Test) .. "$" match = tweaked_pos_id:find(pattern, 1, false) if match ~= nil then diff --git a/lua/neotest-golang/ast.lua b/lua/neotest-golang/query.lua similarity index 100% rename from lua/neotest-golang/ast.lua rename to lua/neotest-golang/query.lua diff --git a/lua/neotest-golang/runspec_dir.lua b/lua/neotest-golang/runspec/dir.lua similarity index 87% rename from lua/neotest-golang/runspec_dir.lua rename to lua/neotest-golang/runspec/dir.lua index bd262320..71b24b07 100644 --- a/lua/neotest-golang/runspec_dir.lua +++ b/lua/neotest-golang/runspec/dir.lua @@ -1,8 +1,7 @@ --- Helpers to build the command and context around running all tests of --- a Go package. -local cmd = require("neotest-golang.cmd") -local find = require("neotest-golang.find") +local lib = require("neotest-golang.lib") local M = {} @@ -15,7 +14,7 @@ local M = {} --- @param pos neotest.Position --- @return neotest.RunSpec | nil function M.build(pos) - local go_mod_filepath = find.file_upwards("go.mod", pos.path) + local go_mod_filepath = lib.find.file_upwards("go.mod", pos.path) if go_mod_filepath == nil then -- if no go.mod file was found up the directory tree, until reaching $CWD, -- then we cannot determine the Go project root. @@ -23,7 +22,7 @@ function M.build(pos) end local go_mod_folderpath = vim.fn.fnamemodify(go_mod_filepath, ":h") - local golist_data = cmd.golist_data(go_mod_folderpath) + local golist_data = lib.cmd.golist_data(go_mod_folderpath) -- find the go package that corresponds to the go_mod_folderpath local package_name = "./..." @@ -38,7 +37,7 @@ function M.build(pos) end end - local test_cmd, json_filepath = cmd.test_command_in_package(package_name) + local test_cmd, json_filepath = lib.cmd.test_command_in_package(package_name) --- @type RunspecContext local context = { diff --git a/lua/neotest-golang/runspec_file.lua b/lua/neotest-golang/runspec/file.lua similarity index 84% rename from lua/neotest-golang/runspec_file.lua rename to lua/neotest-golang/runspec/file.lua index 39e07462..7a8f2543 100644 --- a/lua/neotest-golang/runspec_file.lua +++ b/lua/neotest-golang/runspec/file.lua @@ -1,8 +1,6 @@ --- Helpers to build the command and context around running all tests of a file. -local cmd = require("neotest-golang.cmd") -local convert = require("neotest-golang.convert") -local find = require("neotest-golang.find") +local lib = require("neotest-golang.lib") local M = {} @@ -15,7 +13,7 @@ function M.build(pos, tree) return M.fail_fast(pos) end - local go_mod_filepath = find.file_upwards("go.mod", pos.path) + local go_mod_filepath = lib.find.file_upwards("go.mod", pos.path) if go_mod_filepath == nil then -- if no go.mod file was found up the directory tree, until reaching $CWD, -- then we cannot determine the Go project root. @@ -23,7 +21,7 @@ function M.build(pos, tree) end local go_mod_folderpath = vim.fn.fnamemodify(go_mod_filepath, ":h") - local golist_data = cmd.golist_data(go_mod_folderpath) + local golist_data = lib.cmd.golist_data(go_mod_folderpath) -- find the go package that corresponds to the pos.path local package_name = "./..." @@ -48,10 +46,10 @@ function M.build(pos, tree) local regexp = M.get_regexp(pos.path) if regexp ~= nil then test_cmd, json_filepath = - cmd.test_command_in_package_with_regexp(package_name, regexp) + lib.cmd.test_command_in_package_with_regexp(package_name, regexp) else -- fallback: run all tests in the package - test_cmd, json_filepath = cmd.test_command_in_package(package_name) + test_cmd, json_filepath = lib.cmd.test_command_in_package(package_name) -- NOTE: could also fall back to running on a per-test basis by using a bare return end @@ -99,7 +97,7 @@ function M.get_regexp(filepath) if line:match("func Test") then line = line:gsub("func ", "") line = line:gsub("%(.*", "") - table.insert(lines, convert.to_gotest_regex_pattern(line)) + table.insert(lines, lib.convert.to_gotest_regex_pattern(line)) end end if #lines > 0 then diff --git a/lua/neotest-golang/runspec/init.lua b/lua/neotest-golang/runspec/init.lua new file mode 100644 index 00000000..09b9edb4 --- /dev/null +++ b/lua/neotest-golang/runspec/init.lua @@ -0,0 +1,10 @@ +--- Build the neotest.Runspec specification for a test execution. + +local M = {} + +M.dir = require("neotest-golang.runspec.dir") +M.file = require("neotest-golang.runspec.file") +M.namespace = require("neotest-golang.runspec.namespace") +M.test = require("neotest-golang.runspec.test") + +return M diff --git a/lua/neotest-golang/runspec_namespace.lua b/lua/neotest-golang/runspec/namespace.lua similarity index 69% rename from lua/neotest-golang/runspec_namespace.lua rename to lua/neotest-golang/runspec/namespace.lua index 3aa5de5c..3e3efe68 100644 --- a/lua/neotest-golang/runspec_namespace.lua +++ b/lua/neotest-golang/runspec/namespace.lua @@ -1,7 +1,6 @@ --- Helpers to build the command and context around running all tests in a namespace. -local convert = require("neotest-golang.convert") -local cmd = require("neotest-golang.cmd") +local lib = require("neotest-golang.lib") local M = {} @@ -11,13 +10,13 @@ local M = {} function M.build(pos) --- @type string local test_folder_absolute_path = string.match(pos.path, "(.+)/") - local golist_data = cmd.golist_data(test_folder_absolute_path) + local golist_data = lib.cmd.golist_data(test_folder_absolute_path) --- @type string - local test_name = convert.to_gotest_test_name(pos.id) - test_name = convert.to_gotest_regex_pattern(test_name) + local test_name = lib.convert.to_gotest_test_name(pos.id) + test_name = lib.convert.to_gotest_regex_pattern(test_name) - local test_cmd, json_filepath = cmd.test_command_in_package_with_regexp( + local test_cmd, json_filepath = lib.cmd.test_command_in_package_with_regexp( test_folder_absolute_path, test_name ) diff --git a/lua/neotest-golang/runspec_test.lua b/lua/neotest-golang/runspec/test.lua similarity index 78% rename from lua/neotest-golang/runspec_test.lua rename to lua/neotest-golang/runspec/test.lua index 6376df52..8ad0b2df 100644 --- a/lua/neotest-golang/runspec_test.lua +++ b/lua/neotest-golang/runspec/test.lua @@ -1,8 +1,7 @@ --- Helpers to build the command and context around running a single test. -local convert = require("neotest-golang.convert") +local lib = require("neotest-golang.lib") local options = require("neotest-golang.options") -local cmd = require("neotest-golang.cmd") local dap = require("neotest-golang.features.dap") local M = {} @@ -14,13 +13,13 @@ local M = {} function M.build(pos, strategy) --- @type string local test_folder_absolute_path = string.match(pos.path, "(.+)/") - local golist_data = cmd.golist_data(test_folder_absolute_path) + local golist_data = lib.cmd.golist_data(test_folder_absolute_path) --- @type string - local test_name = convert.to_gotest_test_name(pos.id) - test_name = convert.to_gotest_regex_pattern(test_name) + local test_name = lib.convert.to_gotest_test_name(pos.id) + test_name = lib.convert.to_gotest_regex_pattern(test_name) - local test_cmd, json_filepath = cmd.test_command_in_package_with_regexp( + local test_cmd, json_filepath = lib.cmd.test_command_in_package_with_regexp( test_folder_absolute_path, test_name ) diff --git a/tests/go/testname_spec.lua b/tests/go/testname_spec.lua index 71868db2..d9a146c3 100644 --- a/tests/go/testname_spec.lua +++ b/tests/go/testname_spec.lua @@ -1,6 +1,6 @@ local nio = require("nio") local adapter = require("neotest-golang") -local convert = require("neotest-golang.convert") +local lib = require("neotest-golang.lib") local _ = require("plenary") describe("Neotest position to Go test name", function() @@ -17,7 +17,7 @@ describe("Neotest position to Go test name", function() -- Act local pos = tree:node(3):data() - local actual_go_test_name = convert.to_gotest_test_name(pos.id) + local actual_go_test_name = lib.convert.to_gotest_test_name(pos.id) -- Assert local actual_name = pos.name @@ -36,7 +36,7 @@ describe("Neotest position to Go test name", function() -- Act local pos = tree:node(4):data() - local actual_go_test_name = convert.to_gotest_test_name(pos.id) + local actual_go_test_name = lib.convert.to_gotest_test_name(pos.id) -- Assert local actual_name = pos.name @@ -53,7 +53,7 @@ describe("Neotest position to Go test name", function() -- Act local pos = tree:node(5):data() - local actual_go_test_name = convert.to_gotest_test_name(pos.id) + local actual_go_test_name = lib.convert.to_gotest_test_name(pos.id) -- Assert local actual_name = pos.name @@ -72,7 +72,7 @@ describe("Neotest position to Go test name", function() -- Act local pos = tree:node(8):data() - local actual_go_test_name = convert.to_gotest_test_name(pos.id) + local actual_go_test_name = lib.convert.to_gotest_test_name(pos.id) -- Assert local actual_name = pos.name @@ -98,8 +98,8 @@ describe("Full Go test name conversion", function() -- Act local pos = tree:node(7):data() - local test_name = convert.to_gotest_test_name(pos.id) - test_name = convert.to_gotest_regex_pattern(test_name) + local test_name = lib.convert.to_gotest_test_name(pos.id) + test_name = lib.convert.to_gotest_regex_pattern(test_name) -- Assert local actual_name = pos.name diff --git a/tests/unit/is_test_file_spec.lua b/tests/unit/is_test_file_spec.lua index 1372e5b8..a3ee1115 100644 --- a/tests/unit/is_test_file_spec.lua +++ b/tests/unit/is_test_file_spec.lua @@ -1,4 +1,5 @@ local adapter = require("neotest-golang") +local _ = require("plenary") describe("Is test file", function() it("True - Path to file", function() diff --git a/tests/unit/json_spec.lua b/tests/unit/json_spec.lua index b8526a48..302c1a73 100644 --- a/tests/unit/json_spec.lua +++ b/tests/unit/json_spec.lua @@ -1,4 +1,5 @@ -local json = require("neotest-golang.json") +local lib = require("neotest-golang.lib") +local _ = require("plenary") describe("Go list", function() it("Returns one entry", function() @@ -10,7 +11,7 @@ describe("Go list", function() local expected = { { Dir = "foo" } } assert.are_same( vim.inspect(expected), - vim.inspect(json.process_golist_output(input)) + vim.inspect(lib.json.process_golist_output(input)) ) end) @@ -25,7 +26,7 @@ describe("Go list", function() local expected = { { Dir = "foo" }, { Dir = "bar" } } assert.are_same( vim.inspect(expected), - vim.inspect(json.process_golist_output(input)) + vim.inspect(lib.json.process_golist_output(input)) ) end) @@ -44,7 +45,7 @@ describe("Go list", function() local expected = { { Dir = "foo" }, { Dir = "bar" }, { Dir = "baz" } } assert.are_same( vim.inspect(expected), - vim.inspect(json.process_golist_output(input)) + vim.inspect(lib.json.process_golist_output(input)) ) end) it("Returns nested entries", function() @@ -76,7 +77,7 @@ describe("Go list", function() } assert.are_same( vim.inspect(expected), - vim.inspect(json.process_golist_output(input)) + vim.inspect(lib.json.process_golist_output(input)) ) end) end) diff --git a/tests/unit/options_spec.lua b/tests/unit/options_spec.lua index 8a6f4249..96f5aa7d 100644 --- a/tests/unit/options_spec.lua +++ b/tests/unit/options_spec.lua @@ -1,4 +1,5 @@ local options = require("neotest-golang.options") +local _ = require("plenary") describe("Options are set up", function() it("With defaults", function()