From 70297f28e77839141293dfd966eadc9397490418 Mon Sep 17 00:00:00 2001 From: Smirnov Olexander Date: Tue, 21 Jun 2022 17:35:28 +0300 Subject: [PATCH] feat(gotests): add generate all tests docs(gotests): add generate all tests --- README.md | 7 +++++++ lua/gopher/gotests.lua | 9 +++++++++ lua/gopher/init.lua | 1 + plugin/gopher.vim | 1 + 4 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 3452a9d..c9e970b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ Minimalistic plugin for Go development in Neovim written in Lua. It's not an LSP tool, the main goal of this plugin add go tooling support in neovim. + ## Install Pre-dependency: [go](https://github.com/golang/go) (tested on 1.17 and 1.18) @@ -86,6 +87,12 @@ Generate one test for spesific function/method :GoTestAdd ``` +Generate all tests for all functions/methods in current file + +```vim +:GoTestsAll +``` + 7. Run `go generate` command ```vim diff --git a/lua/gopher/gotests.lua b/lua/gopher/gotests.lua index 55ba454..9366fa7 100644 --- a/lua/gopher/gotests.lua +++ b/lua/gopher/gotests.lua @@ -45,4 +45,13 @@ function M.func_test(parallel) add_test(cmd_args) end +function M.all_tests(parallel) + local cmd_args = { "-all" } + if parallel then + table.insert(cmd_args, "-parallel") + end + + add_test(cmd_args) +end + return M diff --git a/lua/gopher/init.lua b/lua/gopher/init.lua index 6961470..521c1e9 100644 --- a/lua/gopher/init.lua +++ b/lua/gopher/init.lua @@ -10,5 +10,6 @@ gopher.get = require "gopher.goget" gopher.impl = require "gopher.impl" gopher.generate = require "gopher.gogenerate" gopher.test_add = gotests.one_test +gopher.tests_all = gotests.all_tests return gopher diff --git a/plugin/gopher.vim b/plugin/gopher.vim index a919cfb..f01c52c 100644 --- a/plugin/gopher.vim +++ b/plugin/gopher.vim @@ -1,6 +1,7 @@ command! -nargs=* GoTagAdd :lua require"gopher".tags_add() command! -nargs=* GoTagRm :lua require"gopher".tags_rm() command! -nargs=* GoTestAdd :lua require"gopher".test_add() +command! -nargs=* GoTestsAll :lua require"gopher".tests_all() command! -nargs=* GoMod :lua require"gopher".mod() command! -nargs=* GoGet :lua require"gopher".get() command! -nargs=* GoImpl :lua require"gopher".impl()