Skip to content

Commit

Permalink
Mitigate problem with deeper nested level tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergii4 committed Feb 24, 2024
1 parent 627a1cc commit 829faeb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lua/neotest-go/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ function adapter.prepare_results(tree, lines, go_root, go_module)
}
file_id = value.id
else
-- to remove quotes, for example three_level_nested_test.go::TestOdd::"odd"::5_is_odd
local value_id = value.id:gsub('%"', "")
-- mitigates `value.id` such as jsonoutput_test.go::Test_Level_1::"Level 2"::Level_3'
local value_id = value.id:gsub('%"', ""):gsub(" ", "_")
local normalized_id = utils.normalize_id(value_id, go_root, go_module)
local test_result = tests[normalized_id]
-- file level node
Expand Down
1 change: 1 addition & 0 deletions lua/spec/neotest-go/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ describe("prepare_results", function()
test_file .. "::TestOdd::odd",
test_file .. '::TestOdd::"odd"::7_is_odd',
test_file .. '::TestOdd::"odd"::5_is_odd',
test_file .. '::TestOdd::"odd"::"5 is odd"::9_is_odd',
}
-- we should run test from module root
local command = {
Expand Down
5 changes: 5 additions & 0 deletions neotest_go/three_level_nested_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ func TestOdd(t *testing.T) {
if 5%2 != 1 {
t.Error("5 is actually odd")
}
t.Run("9 is odd", func(t *testing.T) {
if 9%2 != 1 {
t.Error("5 is actually odd")
}
})
})
t.Run("7 is odd", func(t *testing.T) {
if 7%2 != 1 {
Expand Down

0 comments on commit 829faeb

Please sign in to comment.