Skip to content

Commit

Permalink
test: add more
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jan 2, 2025
1 parent 335950a commit 32add08
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/go/internal/two/one_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package two

import "testing"

func TestOne(t *testing.T) {}
5 changes: 5 additions & 0 deletions tests/go/internal/two/two_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package two

import "testing"

func TestTwo(t *testing.T) {}
106 changes: 106 additions & 0 deletions tests/unit/golist_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,109 @@ describe("go list output from internal/positions", function()
assert.are_same(expected, first_entry)
end)
end)

describe("go list output from internal/subpackage", function()
it("contains expected keys/values", function()
local tests_filepath = vim.uv.cwd() .. "/tests/go"
local filepath = vim.uv.cwd() .. "/tests/go/internal/subpackage"
local output = lib.cmd.golist_data(filepath)
local first_entry = output
local expected = {
{
Dir = filepath .. "/subpackage2",
ImportPath = "github.com/fredrikaverpil/neotest-golang/internal/subpackage/subpackage2",
Module = {
GoMod = tests_filepath .. "/go.mod",
},
Name = "subpackage2",
TestGoFiles = { "subpackage2_test.go" },
XTestGoFiles = {}, -- NOTE: added here because of custom `go list -f` command
},
{
Dir = filepath .. "/subpackage2/subpackage3",
ImportPath = "github.com/fredrikaverpil/neotest-golang/internal/subpackage/subpackage2/subpackage3",
Module = {
GoMod = tests_filepath .. "/go.mod",
},
Name = "subpackage3",
TestGoFiles = { "subpackage3_test.go" },
XTestGoFiles = {}, -- NOTE: added here because of custom `go list -f` command
},
}

assert.are_same(vim.inspect(expected), vim.inspect(first_entry))
assert.are_same(expected, first_entry)
end)
end)

describe("go list output from internal/x", function()
it("contains expected keys/values", function()
local tests_filepath = vim.uv.cwd() .. "/tests/go"
local filepath = vim.uv.cwd() .. "/tests/go/internal/x"
local output = lib.cmd.golist_data(filepath)
local first_entry = output
local expected = {
{
Dir = filepath,
ImportPath = "github.com/fredrikaverpil/neotest-golang/internal/x",
Module = {
GoMod = tests_filepath .. "/go.mod",
},
Name = "x",
TestGoFiles = { "xtest_whitebox_test.go" },
XTestGoFiles = { "xtest_blackbox_test.go" }, -- NOTE: added here because of custom `go list -f` command
},
}

assert.are_same(vim.inspect(expected), vim.inspect(first_entry))
assert.are_same(expected, first_entry)
end)
end)

describe("go list output from internal/x", function()
it("contains TestGoFiles and XTestGoFiles", function()
local tests_filepath = vim.uv.cwd() .. "/tests/go"
local filepath = vim.uv.cwd() .. "/tests/go/internal/x"
local output = lib.cmd.golist_data(filepath)
local first_entry = output
local expected = {
{
Dir = filepath,
ImportPath = "github.com/fredrikaverpil/neotest-golang/internal/x",
Module = {
GoMod = tests_filepath .. "/go.mod",
},
Name = "x",
TestGoFiles = { "xtest_whitebox_test.go" },
XTestGoFiles = { "xtest_blackbox_test.go" }, -- NOTE: added here because of custom `go list -f` command
},
}

assert.are_same(vim.inspect(expected), vim.inspect(first_entry))
assert.are_same(expected, first_entry)
end)
end)

describe("go list output from internal/two", function()
it("contains two TestGoFiles", function()
local tests_filepath = vim.uv.cwd() .. "/tests/go"
local filepath = vim.uv.cwd() .. "/tests/go/internal/two"
local output = lib.cmd.golist_data(filepath)
local first_entry = output
local expected = {
{
Dir = filepath,
ImportPath = "github.com/fredrikaverpil/neotest-golang/internal/two",
Module = {
GoMod = tests_filepath .. "/go.mod",
},
Name = "two",
TestGoFiles = { "one_test.go", "two_test.go" },
XTestGoFiles = {}, -- NOTE: added here because of custom `go list -f` command
},
}

assert.are_same(vim.inspect(expected), vim.inspect(first_entry))
assert.are_same(expected, first_entry)
end)
end)

0 comments on commit 32add08

Please sign in to comment.