Skip to content

Commit 627a1cc

Browse files
committed
Remove quotes from normalised id
1 parent d08508f commit 627a1cc

File tree

2 files changed

+38
-43
lines changed

2 files changed

+38
-43
lines changed

lua/neotest-go/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ function adapter.prepare_results(tree, lines, go_root, go_module)
242242
if test_result then
243243
local fname = async.fn.tempname()
244244
fn.writefile(test_result.output, fname)
245-
results[value_id] = {
245+
results[value.id] = {
246246
status = test_result.status,
247247
short = table.concat(test_result.output, ""),
248248
output = fname,
249249
}
250250
local errors = utils.get_errors_from_test(test_result, utils.get_filename_from_id(value.id))
251251
if errors then
252-
results[value_id].errors = errors
252+
results[value.id].errors = errors
253253
end
254254
if test_result.status == test_statuses.fail and file_id then
255255
results[file_id].status = test_statuses.fail

lua/spec/neotest-go/init_spec.lua

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -302,50 +302,45 @@ describe("prepare_results", function()
302302
end
303303
end
304304
)
305-
async.it(
306-
"check that all nested results are in three_level_nested_test.go, quotes should be removed from keys",
307-
-- three_level_nested_test.go::TestOdd::odd::5_is_odd
308-
-- not three_level_nested_test.go::TestOdd::"odd"::5_is_odd
309-
function()
310-
local tests_folder = vim.loop.cwd() .. "/neotest_go"
311-
local test_file = tests_folder .. "/three_level_nested_test.go"
312-
local positions = plugin.discover_positions(test_file)
305+
async.it("check that all nested results are in three_level_nested_test.go", function()
306+
local tests_folder = vim.loop.cwd() .. "/neotest_go"
307+
local test_file = tests_folder .. "/three_level_nested_test.go"
308+
local positions = plugin.discover_positions(test_file)
313309

314-
local expected_keys = {
315-
test_file,
316-
test_file .. "::TestOdd",
317-
test_file .. "::TestOdd::odd",
318-
test_file .. "::TestOdd::odd::7_is_odd",
319-
test_file .. "::TestOdd::odd::5_is_odd",
320-
}
321-
-- we should run test from module root
322-
local command = {
323-
"cd",
324-
tests_folder,
325-
"&&",
326-
"go",
327-
"test",
328-
"-v",
329-
"-json",
330-
"",
331-
"-count=1",
332-
"-timeout=60s",
333-
"./...",
334-
}
335-
local handle = io.popen(table.concat(command, " "))
336-
local result = handle:read("*a")
337-
handle:close()
310+
local expected_keys = {
311+
test_file,
312+
test_file .. "::TestOdd",
313+
test_file .. "::TestOdd::odd",
314+
test_file .. '::TestOdd::"odd"::7_is_odd',
315+
test_file .. '::TestOdd::"odd"::5_is_odd',
316+
}
317+
-- we should run test from module root
318+
local command = {
319+
"cd",
320+
tests_folder,
321+
"&&",
322+
"go",
323+
"test",
324+
"-v",
325+
"-json",
326+
"",
327+
"-count=1",
328+
"-timeout=60s",
329+
"./...",
330+
}
331+
local handle = io.popen(table.concat(command, " "))
332+
local result = handle:read("*a")
333+
handle:close()
338334

339-
local lines = {}
340-
for s in result:gmatch("[^\r\n]+") do
341-
table.insert(lines, s)
342-
end
343-
local processed_results = plugin.prepare_results(positions, lines, tests_folder, "neotest_go")
344-
for _, v in pairs(expected_keys) do
345-
assert.has_property(v, processed_results)
346-
end
335+
local lines = {}
336+
for s in result:gmatch("[^\r\n]+") do
337+
table.insert(lines, s)
347338
end
348-
)
339+
local processed_results = plugin.prepare_results(positions, lines, tests_folder, "neotest_go")
340+
for _, v in pairs(expected_keys) do
341+
assert.has_property(v, processed_results)
342+
end
343+
end)
349344

350345
async.it("check that we have correct file level test result status", function()
351346
local tests_folder = vim.loop.cwd() .. "/neotest_go"

0 commit comments

Comments
 (0)