GithubHelp home page GithubHelp logo

neotest-go's People

Contributors

akinsho avatar alesbrelih avatar antoniojcosta avatar bacbia3696 avatar davincible avatar giovanism avatar jens1205 avatar jstensland avatar lunarxlark avatar malefaro avatar michaldziurowski avatar olzhasar avatar rcarriga avatar sergii4 avatar shreyas44 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

neotest-go's Issues

Table tests not recognized when defined inside for-loop

I just noticed that when you define your table tests like this, neotest-go does not recognize individual tests in the table:

func TestSomething(t *testing.T) {
	t.Parallel()
	t.Run("subtest of table tests", func(t *testing.T) {
		t.Parallel()
		for _, tt := range []struct {
			name string
		}{
			{
				name: "missing",
			},
			{
				name: "invalid",
			},
			{
				name: "wildcard not allowed",
			},
		} {
			tt := tt
			t.Run(tt.name, func(t *testing.T) {
				t.Parallel()
				// Act
				// Assert
			})
		}
	})
}

By rewriting them on the form seen in https://github.com/nvim-neotest/neotest-go/blob/main/neotest_go/many_table_test.go fixes the issue. But when you enter a large pre-existing codebase where table tests are defined this way, this is not a helpful workaround as it's hard to motivate refactoring hundreds of tests for this purpose.

I haven't looked into how neotest-go figures out that there are table tests. Treesitter AST inspection?

Test-Table feature only works partially

Using the following test example:

`func TestSomeTest(t *testing.T) {
tt := []struct {
name string
method string
url string
apiKey string
status int
}{
{name: "AccessDenied1", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
{name: "AccessDenied2", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
{name: "AccessDenied3", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
{name: "AccessDenied4", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
{name: "AccessDenied5", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
{name: "AccessDenied6", method: http.MethodGet, url: "/api/nothing", apiKey: "lalala", status: http.StatusForbidden},
}

for _, tc := range tt {
	tc := tc
	t.Run(tc.name, func(t *testing.T) {
		fmt.Println(tc.name, tc.method, tc.url, tc.apiKey, tc.status)
	})
}

}
And running it usinglua require('neotest').run.run()` It will run the whole test but only show checkmarks for some of the tests (seems random which ones it picks). Also looking at the neotest-summary I also just see 2-3 of the tests:
image

I'm using the latest neovim stable 0.8.1 and the latest golang 0.19.4

No tests found

I've read the other closed issues #64 and #51 on this. I suspect this is a similar cause with treesitter changes, but I haven't been able to figure out a resolution.

This is the minimal reproduction configuration I have using lazy.nvim.

repro.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end


-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	"LazyVim/LazyVim",
	{
		"nvim-neotest/neotest",
		dependencies = {
			"nvim-neotest/nvim-nio",
			"nvim-lua/plenary.nvim",
			"nvim-treesitter/nvim-treesitter",
			"nvim-neotest/neotest-go",
		},
		opts = {
			adapters = {
				["neotest-go"] = {
					-- Here we can set options for neotest-go, e.g.
					-- args = { "-tags=integration" }
					recursive_run = true,
				},
			},
		},
	},
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
command! NeotestOutput lua require("neotest").output.open()
]])

Loading this test file, I get to tests found for NeotestFile and NeotestSummary.

repro_test.go

package main

import (
	"regexp"
	"testing"
)

func Hello(msg string) (string, error) {
	return msg, nil
}

func TestFail(t *testing.T) {
	t.Error("Fail :(")
}

// TestHelloName calls greetings.Hello with a name, checking
// for a valid return value.
func TestHelloName(t *testing.T) {
	name := "Gladys"
	want := regexp.MustCompile(`\b` + name + `\b`)
	msg, err := Hello("Gladys")
	if !want.MatchString(msg) || err != nil {
		t.Fatalf(`Hello("Gladys") = %q, %v, want match for %#q, nil`, msg, err, want)
	}
}

// TestHelloEmpty calls greetings.Hello with an empty string,
// checking for an error.
func TestHelloEmpty(t *testing.T) {
	msg, err := Hello("")
	if msg != "" || err == nil {
		t.Fatalf(`Hello("") = %q, %v, want "", error`, msg, err)
	}
}
$ nvim --version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1710088188

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/Users/christopherhoffman/.homebrew/Cellar/neovim/0.9.5/share/nvim"

Run :checkhealth for more info

$ nvim -u repro.lua repro_test.go

The lockfile for lazy.

{
  "LazyVim": { "branch": "main", "commit": "70bc8803306ba26a6362d489751da48633c1164c" },
  "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" },
  "neotest": { "branch": "master", "commit": "e07fe8241112274aae9947b98d255763738a1d52" },
  "neotest-go": { "branch": "main", "commit": "6a2f996d89fe4631942e035b1c114544ee045043" },
  "nvim-nio": { "branch": "master", "commit": "ed70af8ad9d4dafdb55539ed2b4454aac2a2a0c3" },
  "nvim-treesitter": { "branch": "master", "commit": "c28396de30b92a5af049037c2bd543a932a37a78" },
  "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" },
  "tokyonight.nvim": { "branch": "main", "commit": "fbe3a27378fdd51a8ddd04f57012455436916a62" }
}

Cannot run spec tests

Hi, I tried running plenary spec tests but all of them failed. Seems like the test cannot find plugin dependencies.
Here's a screenshot:
image

What am I doing wrong?

nil error on test single function

Hi!

When I run require('neotest').run.run() on a single function with a failing test I get the following stacktrace:

2023-05-08T14:38:41 Neotest ﭧ WARN neotest-go: ...nkich/.local/share/nvim/plugged/neotest/lua/nio/init.lua:105: The coroutine failed with this message:
...al/share/nvim/plugged/neotest-go/lua/neotest-go/init.lua:223: attempt to index a nil value
stack traceback:
        ...al/share/nvim/plugged/neotest-go/lua/neotest-go/init.lua: in function 'results'
        ...share/nvim/plugged/neotest/lua/neotest/client/runner.lua:131: in function '_run_spec'
        ...share/nvim/plugged/neotest/lua/neotest/client/runner.lua:89: in function <...share/nvim/plugged/neotest/lua/neotest/client/runner.lua:88>

Reverting back to 2148ad794e7a5c30c7385a3281f4be91e6b113c4 and executing against the same function I get the proper failed test output.

I was able to reproduce the error with a simple testcase

package main

import "testing"

func TestStackTrace(t *testing.T) {
        t.FailNow()
}

Testing that function with b6dc0b1c49569273d863d7b96b6c81b3fc153e82 will throw a stacktrace while testing with 2148ad794e7a5c30c7385a3281f4be91e6b113c4 correctly reports the error.

Transfer ownership to neotest org

Hi @rcarriga,

Now you've created the neotest organization, I'd be happy to move this repo under that umbrella, although I'd like to maintain access, so I can keep iterating on it. Not sure how privileges work with GitHub orgs, but I'd only need/want push access to this repo.

Don't see any icons

On test declaration level don't see correct icon after test failed

local neotest_ns = vim.api.nvim_create_namespace("neotest")
vim.diagnostic.config({
	virtual_text = {
		format = function(diagnostic)
			local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
			return message
		end,
	},
}, neotest_ns)
require("neotest").setup({
  adapters = {
    require("neotest-go")({
      experimental = {
        test_table = true,
      },
      args = { "-count=1", "-timeout=60s" }
    })
  }
})

image

Test Output in JSON, making it difficult to read

Good afternoon all,

I’m currently transitioning from VS Code to NeoVim, and decided to get started with LazyVim (a pre-configuration using the package manager Lazy.nvim. Apologies in advance if I have missed something obvious;

Neotest seems to complete the testing as expected (closest test, test file, test all files, etc…), I am experiencing two issues:

  • the output (both in the floating window and the output panel) is formatted in JSON,
  • althought the test passes, the test is shown as a fail (red cross)

See example output below:

test output floating window

For the setup, I followed the recommendations from the lazyVim website, and simply added the plugins in the relevant folder:

neotest.lua

[the file preconfigured by LazyVim]

return {
  {
    "folke/which-key.nvim",
    optional = true,
    opts = {
      defaults = {
        ["<leader>t"] = { name = "+test" },
      },
    },
  },
  {
    "nvim-neotest/neotest",
    opts = {
      -- Can be a list of adapters like what neotest expects,
      -- or a list of adapter names,
      -- or a table of adapter names, mapped to adapter configs.
      -- The adapter will then be automatically loaded with the config.
      adapters = {},
      -- Example for loading neotest-go with a custom config
      -- adapters = {
      --   ["neotest-go"] = {
      --     args = { "-tags=integration" },
      --   },
      -- },
      status = { virtual_text = true },
      output = { open_on_run = true },
      quickfix = {
        open = function()
          if require("lazyvim.util").has("trouble.nvim") then
            vim.cmd("Trouble quickfix")
          else
            vim.cmd("copen")
          end
        end,
      },
    },
    config = function(_, opts)
      local neotest_ns = vim.api.nvim_create_namespace("neotest")
      vim.diagnostic.config({
        virtual_text = {
          format = function(diagnostic)
            -- Replace newline and tab characters with space for more compact diagnostics
            local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
            return message
          end,
        },
      }, neotest_ns)
      if opts.adapters then
        local adapters = {}
        for name, config in pairs(opts.adapters or {}) do
          if type(name) == "number" then
            if type(config) == "string" then
              config = require(config)
            end
            adapters[#adapters + 1] = config
          elseif config ~= false then
            local adapter = require(name)
            if type(config) == "table" and not vim.tbl_isempty(config) then
              local meta = getmetatable(adapter)
              if adapter.setup then
                adapter.setup(config)
              elseif meta and meta.__call then
                adapter(config)
              else
                error("Adapter " .. name .. " does not support setup")
              end
            end
            adapters[#adapters + 1] = adapter
          end
        end
        opts.adapters = adapters
      end
      require("neotest").setup(opts)
    end,
    -- stylua: ignore
    keys = {
      { "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
      { "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
      { "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
      { "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
      { "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
      { "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
      { "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" },
    },
  },
  {
    "mfussenegger/nvim-dap",
    optional = true,
    -- stylua: ignore
    keys = {
      { "<leader>td", function() require("neotest").run.run({strategy = "dap"}) end, desc = "Debug Nearest" },
    },
  },
}

neotest.lua

  • Local file that I use to declare the neotest-go adapter:
return {
  "nvim-neotest/neotest",
  optional = true,
  dependencies = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
    "nvim-neotest/neotest-go",
  },
  opts = {
    adapters = {
      ["neotest-go"] = {
        -- Here we can set options for neotest-go, e.g.
        -- args = { "-tags=integration" }
      },
    },
  },
}

neotest-go.lua

[the file I use to declare and load neotest-go]

return {
  "nvim-neotest/neotest-go",
}

I don’t know what I’m missing at this point, I’ve restarted the installation of LazyVim from scratch twice, and the only thing I can think of is the adapter not interpreting or parsing the output of the test, for whatever reason,

Any help would be greatly appreciated :)

Tests having warnings are marked as failed

Hi,
Thank you for neotest-go, great work!

I'm experiencing an issue when tests are being marked as failed when they produce warnings, even though tests themselves pass:
image

Here is the output from go test command:

➜  go-fileserver git:(registry) ✗ go test ./registry -count=1
# github.com/olzhasar/go-fileserver/registry.test
ld: warning: -no_pie is deprecated when targeting new OS versions
ld: warning: non-standard -pagezero_size is deprecated when targeting macOS 13.0 or later
ok      github.com/olzhasar/go-fileserver/registry      0.880s

Failed to run unit test function

I have a simple Golang project and a couple of lines of unit test function. When I run: lua require("neotest").run.run(), it fails with:

directory ../../local/uavm outside main module or its selected dependencies.

I have followed the installation instructions of neotest and neotest-go.

Doesn't work well with testing file

Running

require("neotest").run.run(vim.fn.expand("%"))

while in a Go test file (in this case, a non-main package) results in output like:

# command-line-arguments [command-line-arguments.test]
link_parser/link_parser_test.go:11:9: undefined: ParseLinks
link_parser/link_parser_test.go:12:12: undefined: Link
link_parser/link_parser_test.go:26:9: undefined: ParseLinks
link_parser/link_parser_test.go:27:12: undefined: Link
link_parser/link_parser_test.go:45:9: undefined: ParseLinks
link_parser/link_parser_test.go:46:12: undefined: Link
link_parser/link_parser_test.go:68:9: undefined: ParseLinks
link_parser/link_parser_test.go:69:12: undefined: Link 
FAIL    command-line-arguments [build failed]

Test Output formatted for non-human-readable

When I run a file in Go, the test output is difficult to read:

{"Time":"2022-12-22T21:49:17.327822502-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto"}
{"Time":"2022-12-22T21:49:17.327945324-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto","Output":"=== RUN   TestPhoto\n"}
{"Time":"2022-12-22T21:49:17.327968507-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate"}
{"Time":"2022-12-22T21:49:17.327975801-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate","Output":"=== RUN   TestPhoto/Validate\n"}
{"Time":"2022-12-22T21:49:17.327985449-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/NoErrorsBaseline"}
{"Time":"2022-12-22T21:49:17.32799128-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/NoErrorsBaseline","Output":"=== RUN   TestPhoto/Validate/NoErrorsBaseline\n"}
{"Time":"2022-12-22T21:49:17.327999977-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenPoolIDIsNil"}
{"Time":"2022-12-22T21:49:17.328005487-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenPoolIDIsNil","Output":"=== RUN   TestPhoto/Validate/ErrorsWhenPoolIDIsNil\n"}
{"Time":"2022-12-22T21:49:17.328057425-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenContentIsInvalid"}
{"Time":"2022-12-22T21:49:17.328063607-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenContentIsInvalid","Output":"=== RUN   TestPhoto/Validate/ErrorsWhenContentIsInvalid\n"}
{"Time":"2022-12-22T21:49:17.328075179-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New"}
{"Time":"2022-12-22T21:49:17.328082573-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New","Output":"=== RUN   TestPhoto/New\n"}
{"Time":"2022-12-22T21:49:17.328277881-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsID"}
{"Time":"2022-12-22T21:49:17.328307387-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsID","Output":"=== RUN   TestPhoto/New/SetsID\n"}
{"Time":"2022-12-22T21:49:17.328326183-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsPoolID"}
{"Time":"2022-12-22T21:49:17.32834065-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsPoolID","Output":"=== RUN   TestPhoto/New/SetsPoolID\n"}
{"Time":"2022-12-22T21:49:17.32835652-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsContent"}
{"Time":"2022-12-22T21:49:17.328369845-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsContent","Output":"=== RUN   TestPhoto/New/SetsContent\n"}
{"Time":"2022-12-22T21:49:17.328389071-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto","Output":"--- PASS: TestPhoto (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328404601-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate","Output":"    --- PASS: TestPhoto/Validate (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328421162-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/NoErrorsBaseline","Output":"        --- PASS: TestPhoto/Validate/NoErrorsBaseline (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328438214-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/NoErrorsBaseline","Elapsed":0}
{"Time":"2022-12-22T21:49:17.328458152-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenPoolIDIsNil","Output":"        --- PASS: TestPhoto/Validate/ErrorsWhenPoolIDIsNil (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.32846784-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenPoolIDIsNil","Elapsed":0}
{"Time":"2022-12-22T21:49:17.32847854-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenContentIsInvalid","Output":"        --- PASS: TestPhoto/Validate/ErrorsWhenContentIsInvalid (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328487758-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate/ErrorsWhenContentIsInvalid","Elapsed":0}
{"Time":"2022-12-22T21:49:17.32849429-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/Validate","Elapsed":0}
{"Time":"2022-12-22T21:49:17.328501574-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New","Output":"    --- PASS: TestPhoto/New (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.32851017-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsID","Output":"        --- PASS: TestPhoto/New/SetsID (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328517794-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsID","Elapsed":0}
{"Time":"2022-12-22T21:49:17.328523405-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsPoolID","Output":"        --- PASS: TestPhoto/New/SetsPoolID (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328530388-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsPoolID","Elapsed":0}
{"Time":"2022-12-22T21:49:17.328536089-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsContent","Output":"        --- PASS: TestPhoto/New/SetsContent (0.00s)\n"}
{"Time":"2022-12-22T21:49:17.328542431-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New/SetsContent","Elapsed":0}
{"Time":"2022-12-22T21:49:17.32854738-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto/New","Elapsed":0}
{"Time":"2022-12-22T21:49:17.32855235-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhoto","Elapsed":0}
{"Time":"2022-12-22T21:49:17.328557279-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository"}
{"Time":"2022-12-22T21:49:17.328562198-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"=== RUN   TestPhotoS3Repository\n"}
{"Time":"2022-12-22T21:49:17.333287369-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:17 github.com/testcontainers/testcontainers-go - Connected to docker: \n"}
{"Time":"2022-12-22T21:49:17.333320622-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"  Server Version: 20.10.21\n"}
{"Time":"2022-12-22T21:49:17.333328517-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"  API Version: 1.41\n"}
{"Time":"2022-12-22T21:49:17.333334288-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"  Operating System: Arch Linux\n"}
{"Time":"2022-12-22T21:49:17.333341-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"  Total Memory: 15900 MB\n"}
{"Time":"2022-12-22T21:49:17.360758673-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:17 Starting container id: 99b51a7fe0f6 image: docker.io/testcontainers/ryuk:0.3.4\n"}
{"Time":"2022-12-22T21:49:17.627491606-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:17 Waiting for container id 99b51a7fe0f6 image: docker.io/testcontainers/ryuk:0.3.4\n"}
{"Time":"2022-12-22T21:49:17.830847358-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:17 Container is ready id: 99b51a7fe0f6 image: docker.io/testcontainers/ryuk:0.3.4\n"}
{"Time":"2022-12-22T21:49:17.867058201-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:17 Starting container id: 7ebc0c5e0500 image: localstack/localstack\n"}
{"Time":"2022-12-22T21:49:18.136949838-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:18 Waiting for container id 7ebc0c5e0500 image: localstack/localstack\n"}
{"Time":"2022-12-22T21:49:20.654270755-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"2022/12/22 21:49:20 Container is ready id: 7ebc0c5e0500 image: localstack/localstack\n"}
{"Time":"2022-12-22T21:49:20.655444451-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"Localstack running @ http://172.17.0.4:4566\n"}
{"Time":"2022-12-22T21:49:20.655458578-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"Access Localstack with: `LOCALSTACK_HOST=172.17.0.4 awslocal ...`\n"}
{"Time":"2022-12-22T21:49:21.782431965-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create"}
{"Time":"2022-12-22T21:49:21.782459908-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create","Output":"=== RUN   TestPhotoS3Repository/Create\n"}
{"Time":"2022-12-22T21:49:21.782468674-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess"}
{"Time":"2022-12-22T21:49:21.782473053-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess","Output":"=== RUN   TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess\n"}
{"Time":"2022-12-22T21:49:21.789359473-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/ReturnsPhotosForPool"}
{"Time":"2022-12-22T21:49:21.78936848-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/ReturnsPhotosForPool","Output":"=== RUN   TestPhotoS3Repository/Create/ReturnsPhotosForPool\n"}
{"Time":"2022-12-22T21:49:21.85753788-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages"}
{"Time":"2022-12-22T21:49:21.857568698-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"=== RUN   TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages\n"}
{"Time":"2022-12-22T21:49:22.073357221-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"    repository_suitetest.go:53: \n"}
{"Time":"2022-12-22T21:49:22.073385945-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        \tError Trace:\t/home/hao/Documents/Projects/photopool/photopool-api/internal/models/photo/repository_suitetest.go:53\n"}
{"Time":"2022-12-22T21:49:22.073396946-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        \tError:      \tNot equal: \n"}
{"Time":"2022-12-22T21:49:22.073401835-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        \t            \texpected: 6\n"}
{"Time":"2022-12-22T21:49:22.073406043-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        \t            \tactual  : 1\n"}
{"Time":"2022-12-22T21:49:22.073410422-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        \tTest:       \tTestPhotoS3Repository/Create/DoesNotCreateDuplicateImages\n"}
{"Time":"2022-12-22T21:49:22.073422474-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID"}
{"Time":"2022-12-22T21:49:22.073426251-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID","Output":"=== RUN   TestPhotoS3Repository/GetByPoolID\n"}
{"Time":"2022-12-22T21:49:22.073431942-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool"}
{"Time":"2022-12-22T21:49:22.073435639-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool","Output":"=== RUN   TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool\n"}
{"Time":"2022-12-22T21:49:22.078717932-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID"}
{"Time":"2022-12-22T21:49:22.078728642-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID\n"}
{"Time":"2022-12-22T21:49:22.078736046-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful"}
{"Time":"2022-12-22T21:49:22.078739453-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful\n"}
{"Time":"2022-12-22T21:49:22.103243535-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository"}
{"Time":"2022-12-22T21:49:22.103265917-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository\n"}
{"Time":"2022-12-22T21:49:22.312222743-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist"}
{"Time":"2022-12-22T21:49:22.312252809-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist\n"}
{"Time":"2022-12-22T21:49:22.318610803-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01"}
{"Time":"2022-12-22T21:49:22.31861979-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01","Output":"=== RUN   TestPhotoS3Repository/Create#01\n"}
{"Time":"2022-12-22T21:49:22.318627324-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01/PersistsAPhoto"}
{"Time":"2022-12-22T21:49:22.318634979-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01/PersistsAPhoto","Output":"=== RUN   TestPhotoS3Repository/Create#01/PersistsAPhoto\n"}
{"Time":"2022-12-22T21:49:22.331346707-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01"}
{"Time":"2022-12-22T21:49:22.331365403-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01","Output":"=== RUN   TestPhotoS3Repository/GetByPoolID#01\n"}
{"Time":"2022-12-22T21:49:22.331379349-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool"}
{"Time":"2022-12-22T21:49:22.331386913-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool","Output":"=== RUN   TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool\n"}
{"Time":"2022-12-22T21:49:22.474846665-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01"}
{"Time":"2022-12-22T21:49:22.474877534-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID#01\n"}
{"Time":"2022-12-22T21:49:22.480250407-08:00","Action":"run","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3"}
{"Time":"2022-12-22T21:49:22.480267069-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3","Output":"=== RUN   TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3\n"}
{"Time":"2022-12-22T21:49:22.787197492-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Output":"--- FAIL: TestPhotoS3Repository (5.46s)\n"}
{"Time":"2022-12-22T21:49:22.787262184-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create","Output":"    --- FAIL: TestPhotoS3Repository/Create (0.29s)\n"}
{"Time":"2022-12-22T21:49:22.7872816-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess","Output":"        --- PASS: TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.787305405-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/CreateReturnsNilErrorOnSuccess","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.7873184-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/ReturnsPhotosForPool","Output":"        --- PASS: TestPhotoS3Repository/Create/ReturnsPhotosForPool (0.07s)\n"}
{"Time":"2022-12-22T21:49:22.787326034-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/ReturnsPhotosForPool","Elapsed":0.07}
{"Time":"2022-12-22T21:49:22.787336214-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Output":"        --- FAIL: TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages (0.22s)\n"}
{"Time":"2022-12-22T21:49:22.787343888-08:00","Action":"fail","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create/DoesNotCreateDuplicateImages","Elapsed":0.22}
{"Time":"2022-12-22T21:49:22.787349869-08:00","Action":"fail","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create","Elapsed":0.29}
{"Time":"2022-12-22T21:49:22.787355811-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID","Output":"    --- PASS: TestPhotoS3Repository/GetByPoolID (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.787363645-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool","Output":"        --- PASS: TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.78737168-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID/ReturnsEmptySliceWhenNoPhotosExistForPool","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.787377602-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.787383984-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID","Output":"    --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID (0.24s)\n"}
{"Time":"2022-12-22T21:49:22.787390787-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful","Output":"        --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful (0.02s)\n"}
{"Time":"2022-12-22T21:49:22.78739795-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNilErrorWhenSuccessful","Elapsed":0.02}
{"Time":"2022-12-22T21:49:22.787403921-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository","Output":"        --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository (0.21s)\n"}
{"Time":"2022-12-22T21:49:22.787410694-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/RemovesItFromTheRepository","Elapsed":0.21}
{"Time":"2022-12-22T21:49:22.787417988-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist","Output":"        --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.787425242-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID/ReturnsNotFoundErrorWhenPoolDoesNotExist","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.787430912-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID","Elapsed":0.24}
{"Time":"2022-12-22T21:49:22.787436613-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01","Output":"    --- PASS: TestPhotoS3Repository/Create#01 (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.787443185-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01/PersistsAPhoto","Output":"        --- PASS: TestPhotoS3Repository/Create#01/PersistsAPhoto (0.01s)\n"}
{"Time":"2022-12-22T21:49:22.787449898-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01/PersistsAPhoto","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.787455318-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/Create#01","Elapsed":0.01}
{"Time":"2022-12-22T21:49:22.787460869-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01","Output":"    --- PASS: TestPhotoS3Repository/GetByPoolID#01 (0.14s)\n"}
{"Time":"2022-12-22T21:49:22.787467531-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool","Output":"        --- PASS: TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool (0.14s)\n"}
{"Time":"2022-12-22T21:49:22.787474495-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01/ReturnsAllPhotosForAPool","Elapsed":0.14}
{"Time":"2022-12-22T21:49:22.787480125-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/GetByPoolID#01","Elapsed":0.14}
{"Time":"2022-12-22T21:49:22.787489493-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01","Output":"    --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID#01 (0.03s)\n"}
{"Time":"2022-12-22T21:49:22.78749832-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3","Output":"        --- PASS: TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3 (0.02s)\n"}
{"Time":"2022-12-22T21:49:22.787504792-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01/RemovesTheFileFromS3","Elapsed":0.02}
{"Time":"2022-12-22T21:49:22.787510282-08:00","Action":"pass","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository/DeleteByPoolIDAndID#01","Elapsed":0.03}
{"Time":"2022-12-22T21:49:22.787515602-08:00","Action":"fail","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Test":"TestPhotoS3Repository","Elapsed":5.46}
{"Time":"2022-12-22T21:49:22.787521002-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Output":"FAIL\n"}
{"Time":"2022-12-22T21:49:22.7888967-08:00","Action":"output","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Output":"FAIL\tgithub.com/bitsmithy/photopool-api/internal/models/photo\t5.474s\n"}
{"Time":"2022-12-22T21:49:22.788921106-08:00","Action":"fail","Package":"github.com/bitsmithy/photopool-api/internal/models/photo","Elapsed":5.474}

No Tests Found

I get "No tests Found" Error when I try to run the tests. It is able to recognize the test file, but none of the test functions..

This is an example test file that I'm to trying to run tests on

package main
import "testing"
func TestNewDeck(t *testing.T) {
    d := newDeck()
    if len(d) != 16 {
        t.Errorf("Expected deck length of 16 but got %v", len(d))
    }
    if d[0] != "Ace of Spades" {
        t.Errorf("Expected first card of Ace of Spades but got %v", d[0])
    }
    if d[len(d) - 1] != "Four of Clubs" {
        t.Errorf("Expected last card of Four of Clubs but got %v", d[len(d) - 1])
    }
}

And this is my neotest-go config

require("neotest").setup({
    adapters = {
        require("neotest-go")({
              experimental = {
                  test_table = true,
              },
              args = { "-timeout=20s" },
            }),
        }
})

Test coverage generation is not working properly due to cwd being changed to the test file directory.

Hello.
Recently a PR Enable run file tests despite nvim current directory was merged, and introduced a major change in how the test are being executed. It all comes down to the fact that currently, the go test ... command will be executed inside the tests file directory. This behavior has been hard-coded into the test command itself:

 local command = vim.tbl_flatten({
    "cd",
    dir,
    "&&",
    "go",
    "test",
    "-v",
    "-json",
    utils.get_build_tags(),
    vim.list_extend(get_args(), args.extra_args or {}),
    unpack(cmd_args),
  })

making it impossible to disable.

First of all I think it is a rather unexpected behavior, and I would assume that the go test... command would run from nvim cwd by default.

Second of all I found out that I'm not able to properly generate code coverage when the go test... is not executed from go.mod dir.
Specifically my problem is with generating coverage for modules outside the test directory. Usually I would generate the coverage with a command like: go test -coverprofile=./coverage.out -coverpkg ./... <TEST_PATH_AND_TAGS> This would generate coverage for the whole project. Now when I comment out the 3 lines

    "cd",
    dir,
    "&&",

and run require("neotest").run.run({ extra_args = {"-coverprofile=./coverage.out", "-coverpkg ./..."} }) I get the result I'm expecting.
However with the cd in place I get only the coverage from the level of the test dir.
I have tried to provide absolute paths:
require("neotest").run.run({ extra_args = {"-coverprofile=".. vim.fn.getcwd() .."/coverage.out", "-coverpkg " .. vim.fn.getcwd() .. "/..."} })
and while this trick works for the coverprofile output file, it does not work for coverpkg path, and i get an error:
warning: no packages being tested depend on matches for pattern PATH_TO_MY_PROJECT.

If this wouldn't be to much trouble, I would like to see at least an option to enable/disable the cwd change.
Thanks !

Broken output when non-json lines occur

The go test -json package has a tendency to include non-json output in some cases. For example when one (distant) sub-package doesn't compile. As a result of this, if I have one not-compiling file in my whole project, non of my tests will report as passing, even though they pass, and the log output will not be parsed.

The problematic code is here;

local ok, parsed = pcall(vim.json.decode, line, { luanil = { object = true } })
if not ok then
log = vim.tbl_map(function(l)
return highlight_output(l)
end, lines)
return tests, log
end

It happens because it now returns prematurely when one line has no valid json. We can either ignore the line here, or try to include it as is.

How do you want to handle this scenario? I can implement a fix

'No tests found' using minimal config

Context
With my default config, I do not have problems running any tests, however, diagnostics are not set. If I can manage to reproduce this issue with a minimal config, I'll create another issue.
To debug this issue, I want to run neotest-go with a minimal config.

Neovim Version
I am running Neovim on macOS; nvim --version output:

NVIM v0.10.0-dev-1390+g0451391ec-Homebrew
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-0451391/share/nvim"

Run :checkhealth for more info

Minimal config
This is the config I am using:

-- ignore default config and plugins
vim.opt.runtimepath:remove(vim.fn.expand("~/.config/nvim"))
vim.opt.packpath:remove(vim.fn.expand("~/.local/share/nvim/site"))
vim.opt.termguicolors = true

-- append test directory
local test_dir = "/tmp/nvim-config"
vim.opt.runtimepath:append(vim.fn.expand(test_dir))
vim.opt.packpath:append(vim.fn.expand(test_dir))

-- install packer
local install_path = test_dir .. "/pack/packer/start/packer.nvim"
local install_plugins = false

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " .. install_path)
  vim.cmd("packadd packer.nvim")
  install_plugins = true
end
local packer = require("packer")

packer.init({
  package_root = test_dir .. "/pack",
  compile_path = test_dir .. "/plugin/packer_compiled.lua",
})

packer.startup(function(use)
  use("wbthomason/packer.nvim")
  use({
    "nvim-neotest/neotest",
    requires = {
    "nvim-lua/plenary.nvim",
    "nvim-treesitter/nvim-treesitter",
    "antoinemadec/FixCursorHold.nvim",
    "nvim-neotest/neotest-go",
    -- Your other test adapters here
    },
    config = function()
      -- get neotest namespace (api call creates or returns namespace)
      local neotest_ns = vim.api.nvim_create_namespace("neotest")
      vim.diagnostic.config({
        virtual_text = {
          format = function(diagnostic)
            local message =
              diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
            return message
          end,
        },
      }, neotest_ns)
      require("neotest").setup({
        -- your neotest config here
        adapters = {
          require("neotest-go"),
        },
      })
    end,
  })
  if install_plugins then
    packer.sync()
  end
end)

vim.cmd([[
command! NeotestSummary lua require("neotest").summary.toggle()
command! NeotestFile lua require("neotest").run.run(vim.fn.expand("%"))
command! Neotest lua require("neotest").run.run(vim.fn.getcwd())
command! NeotestNearest lua require("neotest").run.run()
command! NeotestDebug lua require("neotest").run.run({ strategy = "dap" })
command! NeotestAttach lua require("neotest").run.attach()
command! NeotestOutput lua require("neotest").output.open()
]])

If I try to run the tests in this file:

package greetings

import (
	"regexp"
	"testing"
)

func TestFail(t *testing.T) {
	t.Error("Fail :(")
}

// TestHelloName calls greetings.Hello with a name, checking
// for a valid return value.
func TestHelloName(t *testing.T) {
	name := "Gladys"
	want := regexp.MustCompile(`\b` + name + `\b`)
	msg, err := Hello("Gladys")
	if !want.MatchString(msg) || err != nil {
		t.Fatalf(`Hello("Gladys") = %q, %v, want match for %#q, nil`, msg, err, want)
	}
}

// TestHelloEmpty calls greetings.Hello with an empty string,
// checking for an error.
func TestHelloEmpty(t *testing.T) {
	msg, err := Hello("")
	if msg != "" || err == nil {
		t.Fatalf(`Hello("") = %q, %v, want "", error`, msg, err)
	}
}

I only see the message 'No tests found'.

The logs only contain this:

INFO | 2023-05-18T14:30:20Z+0200 | ...hare/nvim/plugged/neotest/lua/neotest/lib/subprocess.lua:83 | CHILD | Connected to parent instance
INFO | 2023-05-18T14:33:07Z+0200 | ...l/share/nvim/plugged/neotest/lua/neotest/config/init.lua:305 | Configuration complete
DEBUG | 2023-05-18T14:33:07Z+0200 | ...l/share/nvim/plugged/neotest/lua/neotest/config/init.lua:306 | User config {
  adapters = { {
      _generate_position_id = <function 1>,
      build_spec = <function 2>,
      discover_positions = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-go",
      prepare_results = <function 5>,
      results = <function 6>,
      root = <function 7>,
      <metatable> = {
        __call = <function 8>
      }
    } },
  benchmark = {
    enabled = true
  },
  consumers = {},
  default_strategy = "integrated",
  diagnostic = {
    enabled = true,
    severity = 1
  },
  discovery = {
    concurrent = 16,
    enabled = true
  },
  floating = {
    border = "rounded",
    max_height = 0.6,
    max_width = 0.6,
    options = {}
  },
  highlights = {
    adapter_name = "NeotestAdapterName",
    border = "NeotestBorder",
    dir = "NeotestDir",
    expand_marker = "NeotestExpandMarker",
    failed = "NeotestFailed",
    file = "NeotestFile",
    focused = "NeotestFocused",
    indent = "NeotestIndent",
    marked = "NeotestMarked",
    namespace = "NeotestNamespace",
    passed = "NeotestPassed",
    running = "NeotestRunning",
    select_win = "NeotestWinSelect",
    skipped = "NeotestSkipped",
    target = "NeotestTarget",
    test = "NeotestTest",
    unknown = "NeotestUnknown"
  },
  icons = {
    child_indent = "│",
    child_prefix = "├",
    collapsed = "─",
    expanded = "╮",
    failed = "",
    final_child_indent = " ",
    final_child_prefix = "╰",
    non_collapsible = "─",
    passed = "",
    running = "",
    running_animated = { "/", "|", "\\", "-", "/", "|", "\\", "-" },
    skipped = "",
    unknown = ""
  },
  jump = {
    enabled = true
  },
  log_level = 1,
  output = {
    enabled = true,
    open_on_run = "short"
  },
  output_panel = {
    enabled = true,
    open = "botright split | resize 15"
  },
  projects = {
    <metatable> = {
      __index = <function 9>
    }
  },
  quickfix = {
    enabled = false,
    open = true
  },
  run = {
    enabled = true
  },
  running = {
    concurrent = true
  },
  state = {
    enabled = false
  },
  status = {
    enabled = false,
    signs = true,
    virtual_text = false
  },
  strategies = {
    integrated = {
      height = 40,
      width = 120
    }
  },
  summary = {
    animated = true,
    enabled = false,
    expand_errors = true,
    follow = true,
    mappings = {
      attach = "a",
      clear_marked = "M",
      clear_target = "T",
      debug = "d",
      debug_marked = "D",
      expand = { "<CR>", "<2-LeftMouse>" },
      expand_all = "e",
      jumpto = "i",
      mark = "m",
      next_failed = "J",
      output = "o",
      prev_failed = "K",
      run = "r",
      run_marked = "R",
      short = "O",
      stop = "u",
      target = "t"
    },
    open = "botright vsplit | vertical resize 50"
  }
}

So, no call to go test

Error with Neotest-go, subtests and skipping them.

I ran into an error where some strange behaviour happens when you mix tests and subtests that may or may not print out stuff.

I'm not too much into the Neotest-go code to know how why this happens, but here's the code and the error for anyone wanting to reproduce it and dive in.

package lexer

import (
	"testing"
)

func TestNeoTestGo(t *testing.T) {
	t.Run("TestNeoTestGo2", func(t *testing.T) {
		t.Parallel()
		t.Log("Hello NeotestGo")
	})

	t.Run("TestNeoTestGo3", func(t *testing.T) {
		t.Run("TestNeoTestGo3.1", func(t *testing.T) {
			t.Skip()
			t.Parallel()
			t.Log("TestNeoTestGo3.1")
		})
	})
}

When I hold my cursor over line 13, which says "TestNeoTestGo3" and run the test file, I get the following error:

...cal/share/nvim/lazy/neotest-go/lua/neotest-go/output.lua:84: bad argument #1 to 'insert' (table expected, got nil)
stack traceback:
	[C]: in function 'insert'
	...cal/share/nvim/lazy/neotest-go/lua/neotest-go/output.lua:84: in function 'marshal_gotest_output'
	...local/share/nvim/lazy/neotest-go/lua/neotest-go/init.lua:214: in function 'results'
	...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:132: in function '_run_spec'
	...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:89: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:88>

Neovim stats:

NVIM v0.10.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Run "nvim -V1 -v" for more info

Neotest branch 89a5b1f
Neotest-go branch ba5d536

Looking into the code of Neotest-go, looking into the neotest-go/output.lua file
We have:

       .....
          else
            tests[testname].file_output[testfile][linenumber] = {}
          end
        end

        -- if we are in the context of a file, collect the logged data
        if testfile and linenumber and utils.is_test_logoutput(parsed.Output) then
          table.insert(
            tests[testname].file_output[testfile][linenumber],
            sanitize_output(parsed.Output)
          )
        end
      .....

If I add the following line, I seem to fix it. However I have zero clue if this is actually the appropriate fix or if it breaks something else. I was hoping someone with a bit more knowledge of the repo could tip in. I added the following:

       .....
          else
            tests[testname].file_output[testfile][linenumber] = {}
          end
        end

        -- if we are in the context of a file, collect the logged data
        if testfile and linenumber and utils.is_test_logoutput(parsed.Output) then
            if not tests[testname].file_output[testfile][linenumber] then
              tests[testname].file_output[testfile][linenumber] = {}
            end
          table.insert(
            tests[testname].file_output[testfile][linenumber],
            sanitize_output(parsed.Output)
          )
        end
      .....

I reproduced this both on WSL and MacOS.
Let me know if I can help provide more information if needed.
Thanks in advance.

TesetMain support

I love this plugin ❤️

I think this plugin need to support TestMain.

  1. TestMain is executed before the test function is executed. (Right now, TestMain is not executed when individual tests are run)
  2. exclude TestMain from summary. (Not really important.)

I would like to hear function opinions on TestMain. Thanks.

Specify environment variables

What is the proper way to specify some static environment variables to set when running a test for a single workspace?

cannot run unit tests

Hi,

I want to make a PR for a bug which I encountered. I wanted to add a test case to the suites and run unit tests like this:

nvim --headless -c ':PlenaryBustedDirectory lua/spec'

Unfortunately this does not work. All tests are in status "Scheduling" forever. It seems like an issue with plenary.nvim. I am using lazy.nvim as my package manager.

Am I missing something?

Feature request: Add diagnostics for table tests.

Hi,
Currently I have support for table tests enabled with experimental = { test_table = true } but diagnostics are only shown at the assertion, while the symbols are shown at the table-level.
It would be nice to also have the diagnostic at the test-table level.
I had a look in the code and it seems that this should be possible within marshal_gotest_output (lua/neotest-go/output.lua:26).

We get the exact test name + file so we should be able to get the test with some Treesitter magic.
If anyone could help, or has a more deep understanding of the plugin and can quickly implement this, feel free.
If not, I'll try to see if I can implement this if I have some more free time.

Fails when Go code is in a subdirectory (e.g. in a polyglot project)

Not sure if this is an issue with neotest-go or neotest -- let me know if I should move it.

I have a project with multiple languages in use, and my Go code lives under a go/ subdirectory. When running tests with a Go file open, it should try to find the closest go.mod file to the current file, and run the go test command with that directory as its working directory.

Currently it just runs tests in current working directory, which does not work for this use case.

New Contributors

Hey all,

So for a little bit of context I created this neotest extension off the back of @rcarriga great plugin as I was keen to use neotest with go. Unfortunately I don't currently work very much with go ATM (which could change) but in the meantime it would be great if anyone who is actively using this plugin and wants to help improve it could step forward and @rcarriga can hopefully add them to project so they can merge changes etc. and aren't dependent on me. I'm not completely gone but definitely not worth poking me or waiting on me as I'm also not actively monitoring this repo.

@sergii4 I've noticed you've been active on some issues. Would this interest you?

"Run nearest" runs all tests

When I "run nearest test" (require("neotest").run.run()) when positioning my cursor on the test function, I can see how neotest-go executes all tests.

Inspecting the go test command generated by neotest-go

I inspected the go test command produced by printing the command variable value in init.lua:

local command = vim.tbl_flatten({
  ...
})
print(vim.inspect(command))

...which gave me this command:

{ "cd", "/Users/fredrik/code/public/go-playground/bugs/neotest-go", "&&", "go", "test", "-v", "-json", "", "-coverprofile=/Users/fredrik/code/public/go-playground/bugs/neotest-go/coverage.out", "./" }

Note that I'm adding coverprofile myself here.

I would've expected something different, such as having added the -run flag to go test along with a regex matching the test name to the command. For example: go test -run ^Test_Level_1$ to the command.

Inspecting the tests map returned by marshal_gotest_output.tests

I then inspected the value of the tests returned from marshal_gotest_output which again shows how a bunch of tests in other files are being executed.

{
 ["neotest-go::TestAdd"] = {
   file_output = {},
   output = { "=== RUN   TestAdd\n", "\27[32m--- PASS: TestAdd (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 },
 ["neotest-go::TestAddSubTestLevel1"] = {
   file_output = {},
   output = { "=== RUN   TestAddSubTestLevel1\n", "=== RUN   TestAddSubTestLevel1/Add1\n", "\27[32m--- PASS: TestAddSubTestLevel1 (0.00s)\n\27[0m", "\27[32m    --- PASS: TestAddSubTestLevel1/Add1 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 },
 ["neotest-go::TestAddSubTestLevel1::Add1"] = {
   file_output = {},
   output = { "=== RUN   TestAddSubTestLevel1/Add1\n", "\27[32m    --- PASS: TestAddSubTestLevel1/Add1 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 },
 ["neotest-go::TestAddSubTestLevel2"] = {
   file_output = {},
   output = { "=== RUN   TestAddSubTestLevel2\n", "=== RUN   TestAddSubTestLevel2/Add1\n", "=== RUN   TestAddSubTestLevel2/Add1/Add2\n", "    marshaloutput_test.go:31: 1 + 2 did not equal 3\n", "\27[31m--- FAIL: TestAddSubTestLevel2 (0.00s)\n\27[0m", "\27[31m    --- FAIL: TestAddSubTestLevel2/Add1 (0.00s)\n\27[0m", "\27[31m        --- FAIL: TestAddSubTestLevel2/Add1/Add2 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "fail" },
   status = "failed"
 },
 ["neotest-go::TestAddSubTestLevel2::Add1"] = {
   file_output = {},
   output = { "=== RUN   TestAddSubTestLevel2/Add1\n", "\27[31m    --- FAIL: TestAddSubTestLevel2/Add1 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "fail" },
   status = "failed"
 },
 ["neotest-go::TestAddSubTestLevel2::Add1::Add2"] = {
   file_output = {
     ["marshaloutput_test.go"] = {
       [31] = { "1 + 2 did not equal 3\n", "--- FAIL: TestAddSubTestLevel2/Add1/Add2 (0.00s)\n" }
     }
   },
   output = { "=== RUN   TestAddSubTestLevel2/Add1/Add2\n", "    marshaloutput_test.go:31: 1 + 2 did not equal 3\n", "\27[31m        --- FAIL: TestAddSubTestLevel2/Add1/Add2 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "output", "fail" },
   status = "failed"
 },
 ["neotest-go::Test_Level_1"] = {
   file_output = {},
   output = { "=== RUN   Test_Level_1\n", "=== RUN   Test_Level_1/Level_2\n", "=== RUN   Test_Level_1/Level_2/Level_3\n", "\27[32m--- PASS: Test_Level_1 (0.00s)\n\27[0m", "\27[32m    --- PASS: Test_Level_1/Level_2 (0.00s)\n\27[0m", "\27[32m        --- PASS: Test_Level_1/Level_2/Level_3 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 },
 ["neotest-go::Test_Level_1::Level_2"] = {
   file_output = {},
   output = { "=== RUN   Test_Level_1/Level_2\n", "\27[32m    --- PASS: Test_Level_1/Level_2 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 },
 ["neotest-go::Test_Level_1::Level_2::Level_3"] = {
   file_output = {},
   output = { "=== RUN   Test_Level_1/Level_2/Level_3\n", "\27[32m        --- PASS: Test_Level_1/Level_2/Level_3 (0.00s)\n\27[0m" },
   progress = { "run", "output", "output", "pass" },
   status = "passed"
 }
}

Error while testing a file/directory with failed test cases

Reproduce

  1. Run
:lua require('neotest').run.run("path/to/file/or/directory") -- please replace value 

Unfortunately, I cannot provide the code, however, I guess you can use your own one.

  1. A bottom panel will be displayed with error lines. Select a random item immediately and press Enter

  2. The error will be displayed.

Error output

Error executing vim.schedule lua callback: ...local/share/nvim_ansidev/lazy/neotest/lua/nio/tasks.lua:95: Async task failed without callback: The coroutine failed with this message:
...nsidev/lazy/neotest/lua/neotest/consumers/diagnostic.lua:95: attempt to perform arithmetic on a nil value
stack traceback:
        ...nsidev/lazy/neotest/lua/neotest/consumers/diagnostic.lua: in function 'create_diagnostics'
        ...nsidev/lazy/neotest/lua/neotest/consumers/diagnostic.lua:54: in function 'draw_buffer'
        ...nsidev/lazy/neotest/lua/neotest/consumers/diagnostic.lua:163: in function 'draw_buffer'
        ...nsidev/lazy/neotest/lua/neotest/consumers/diagnostic.lua:173: in function 'listener'
        ..._ansidev/lazy/neotest/lua/neotest/client/events/init.lua:51: in function <..._ansidev/lazy/neotest/lua/neotest/client/events/init.lua:47>
stack traceback:
        [C]: in function 'error'
        ....local/share/nvim_ansidev/lazy/neotest/lua/nio/tasks.lua:95: in function 'close_task'
        ....local/share/nvim_ansidev/lazy/neotest/lua/nio/tasks.lua:117: in function 'cb'
        ....local/share/nvim_ansidev/lazy/neotest/lua/nio/tasks.lua:179: in function <....local/share/nvim_ansidev/lazy/neotest/lua/nio/tasks.lua:178>

neotest-go adapter being used for typescript files when repo has both typescript and go

I have a few repos that have both typescript and go in them. I've noticed that when trying to run tests for the typescript code, the neotest-go adapter is being used.

Here's my config:

	require("neotest").setup({
		quickfix = {
			enabled = true,
		},
		log_level = vim.log.levels.DEBUG,
		adapters = {
			require("neotest-vim-test")({
				ignore_file_types = { "go" },
			}),

			require("neotest-go")({
				experimental = {
					test_table = true,
				},
			}),
		},
	})

When I remove neotest-go, I'm able to run both typescript and go tests just fine using the neotest-vim-test adapter. However, I miss out on the table test functionality which is the whole thing that brought me to neotest in the first place. When I add neotest-go, running the same test yields the following debug message:

DEBUG | 2024-01-25T15:37:23Z-0700 | .../pack/packer/start/neotest/lua/neotest/adapters/init.lua:19 | Adapters: { {
    adapter = {
      _generate_position_id = <function 1>,
      build_spec = <function 2>,
      discover_positions = <function 3>,
      is_test_file = <function 4>,
      name = "neotest-go",
      prepare_results = <function 5>,
      results = <function 6>,
      root = <function 7>,
      <metatable> = {
        __call = <function 8>
      }
    },
    root = "/home/twhitney/workspace/some-typescript-repo"
  } }

The file I'm trying to run here is github.test.ts so there's no _test.go in the filename at all, but I'm assuming that since I have a go.mod at the root of this repo (as well as a package.json). the neotest-go adapter is trying to take over. Any way to work around this?

QUESTION: run tests for entire project?

Just wondering if there was a way to run the entire project?

I've tried require('neotest').run.run(vim.fn.getcwd()) as well as require('neotest').run.run('./...') but neither worked.
Wondering if I'm just doing it wrong, or should I fork this and try to implement support for it?

[Feature request] args optional setup argument

Hi

Can we get optional setup argument args like in neotest-python to provide extra_args from setup ?
For example:

require('neotest-go')({
    args = {"-timeout=60s","-count=1"}
})

Because providing them via neotest.run.run({extra_args={...}}) forces them to be specified in key bindings, which is not necessary when using neotest in other languages and may conflicts

[feature request] Table-driven tests written as map[string]struct{}

Following the recent fixes, I now use the table-driven support extensively, and it's become essential to me.

Some of the table-driven tests I work on were written as map[string]struct{...}, following the advice by Dave Cheney (https://dave.cheney.net/2019/05/07/prefer-table-driven-tests), and these are not detected.

I tried to hack the Tree Sitter query myself into something like the snippet at the bottom, but I don't seem to be able to obtain a working solution.

I'll keep trying as this would be a killer feature for me, but in the meantime I would also like to ask for your help, if you had the time to look into this you would have my undying gratitude.

Thank you! 🙂


PS: This is my attempt, it kind-of works in the online Tree Sitter Playground, as it catches the expected elements, but then it breaks if I try and use it in place of the original query

(block
    (short_var_declaration
        left: (expression_list
            (identifier) @test.cases
        )
        right: (expression_list
            (composite_literal
                type: (map_type
                    key: (type_identifier) @test.key.type 
                    	(#eq? @test.key.type "string")
                    value: (struct_type)
                )
                body: (literal_value
                    .(keyed_element
                        (interpreted_string_literal) @test.name
                    )
                ) @test.definition
            )
        )
    )
    (for_statement
    	(range_clause
        	left: (expression_list
            	(identifier) @test.name1
                	(#eq @test.name @test.name1)
                (identifier) @test.case
            )
            right: (identifier) @test.cases1
            	(#eq? @test.cases @test.cases1)
        )
        body: (block
        	(call_expression
            	function: (selector_expression
                	field: (field_identifier) @test.method
                )
                	(#match? @test.method "^Run$")
                arguments: (argument_list
                	(identifier) @test.name2
                    	(#eq? @test.name1 @test.name2)
                )
            )
        )
    )
)

Feat - Add Support for Nested Subtests

Summary

As far as I can tell, neotest-go currently lacks support to run individual nested subtests. Specificallly, it will fail to initiate the right sub-subtest when running the nearest test. I'm working on a PR to add support.

Root cause

The utils.get_prefix, which derives the test to pass to go test -run, assumes that subtests only go one level deep. I fixed that for now, but the results still aren't parsed correctly - I'll publish my PR once I fix that.

Reproduction steps

Create a test file as such:

package main

import (
	"testing"

	"github.com/test-go/testify/require"
)

func TestHello(t *testing.T) {
	t.Run("World", func(t *testing.T) {
		require.Equal(t, "Hello, World!", hello("World"))
	})
	t.Run("Afterlife", func(t *testing.T) {
		t.Run("Heaven", func(t *testing.T) {
			require.Equal(t, "Hello, Heaven!", hello("Heaven"))
		})
		t.Run("Hell", func(t *testing.T) {
			require.Equal(t, "Hello, Hell!", hello("Hell"))
		})
	})
}
  1. Hover over t.Run("World", ... and run require("neotest").run.run(), observe that the test runs correctly.
  2. Hover over t.Run("Heaven", .., and run require("neotest").run.run(), observe that the test is skipped.

neotest-go not found?

Here's my setup, maybe it has to do with having a conflicting module?

use({
	"nvim-neotest/neotest",
	requires = {
		"nvim-neotest/neotest-go",
		"mrcjkb/neotest-haskell",
		"haydenmeade/neotest-jest",
		"nvim-neotest/neotest-plenary",
		"nvim-neotest/neotest-python",
		"rouge8/neotest-rust",
	},
	config = function()
		require("neotest").setup({
			adapters = {
				require("neotest-go")({
					args = { "-count=1", "-timeout=60s" },
				}),
				require("neotest-haskell"),
				require("neotest-jest"),
				require("neotest-plenary"),
				require("neotest-python")({
					dap = { justMyCode = false },
				}),
				require("neotest-rust"),
			},
		})
	end,
})

Error:

packer.nvim: Error running config for neotest: [string "..."]:0: module 'neotest-go' not found:
	no field package.preload['neotest-go']
	no file './neotest-go.lua'
	no file '/home/amaanq/neovim/.deps/usr/share/luajit-2.1.0-beta3/neotest-go.lua'
	no file '/usr/local/share/lua/5.1/neotest-go.lua'
	no file '/usr/local/share/lua/5.1/neotest-go/init.lua'
	no file '/home/amaanq/neovim/.deps/usr/share/lua/5.1/neotest-go.lua'
	no file '/home/amaanq/neovim/.deps/usr/share/lua/5.1/neotest-go/init.lua'
	no file '/home/amaanq/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/neotest-go.lua'
	no file '/home/amaanq/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/neotest-go/init.lua'
	no file '/home/amaanq/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/neotest-go.lua'
	no file '/home/amaanq/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/neotest-go/init.lua'
	no file './neotest-go.so'
	no file '/usr/local/lib/lua/5.1/neotest-go.so'
	no file '/home/amaanq/neovim/.deps/usr/lib/lua/5.1/neotest-go.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/home/amaanq/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/neotest-go.so'

how to add test binary flags

Hi, sorry how can i add the test binary flags? it needs to be after the package -args

	-args
	    Pass the remainder of the command line (everything after -args)
	    to the test binary, uninterpreted and unchanged.
	    Because this flag consumes the remainder of the command line,
	    the package list (if present) must appear before this flag.
	    ```

Running package tests

I'm not sure if this is a feature request or a question, but I can't seem to run a single go package's tests. Trying to pass a folder looks like it results in changing to that directory and running the tests for all sub folders, a command like

cd ./target/package && go test -v -json ./...

But I want something more like

go test -v -json ./target/package

or cd and then use .

The Usage > Test file in the README does the same thing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.