Skip to content

Commit

Permalink
test: golist key/values used by adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jul 13, 2024
1 parent 305e33b commit 1949b5f
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions tests/unit/golist_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
local _ = require("plenary")

local lib = require("neotest-golang.lib")

describe("go list output", function()
it("contains expected keys/values", function()
local tests_filepath = vim.loop.cwd() .. "/tests/go"
local output = lib.cmd.golist_data(tests_filepath)
local first_entry = output[1]
local expected = {

Deps = {
"cmp",
"errors",
"fmt",
"internal/abi",
"internal/bytealg",
"internal/chacha8rand",
"internal/coverage/rtcov",
"internal/cpu",
"internal/fmtsort",
"internal/goarch",
"internal/godebugs",
"internal/goexperiment",
"internal/goos",
"internal/itoa",
"internal/oserror",
"internal/poll",
"internal/race",
"internal/reflectlite",
"internal/safefilepath",
"internal/syscall/execenv",
"internal/syscall/unix",
"internal/testlog",
"internal/unsafeheader",
"io",
"io/fs",
"math",
"math/bits",
"os",
"path",
"reflect",
"runtime",
"runtime/internal/atomic",
"runtime/internal/math",
"runtime/internal/sys",
"slices",
"sort",
"strconv",
"sync",
"sync/atomic",
"syscall",
"time",
"unicode",
"unicode/utf8",
"unsafe",
},
Dir = tests_filepath,
GoFiles = { "main.go" },
ImportPath = "github.com/fredrikaverpil/neotest-golang",
Imports = { "fmt" },
Match = { "./..." },
Module = {
Dir = tests_filepath,
GoMod = tests_filepath .. "/go.mod",
GoVersion = "1.22.2",
Main = true,
Path = "github.com/fredrikaverpil/neotest-golang",
},
Name = "main",
Root = tests_filepath,
Stale = true,
StaleReason = "build ID mismatch",
Target = "/Users/fredrik/go/bin/neotest-golang",
TestGoFiles = { "positions_test.go", "testname_test.go" },
TestImports = { "testing" },
}

-- ignored keys, as they might differ between OS/CI/platforms/too often
expected.Module.GoVersion = nil
first_entry.Module.GoVersion = nil
expected.Deps = nil
first_entry.Deps = nil

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

0 comments on commit 1949b5f

Please sign in to comment.