-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddae100
commit eb5ae3c
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
local nio = require("nio") | ||
local adapter = require("neotest-golang") | ||
local convert = require("neotest-golang.convert") | ||
|
||
describe("Test names conversion", function() | ||
-- Arrange | ||
local test_filepath = vim.loop.cwd() .. "/tests/go/testname_test.go" | ||
|
||
---@type neotest.Tree | ||
local tree = | ||
nio.tests.with_async_context(adapter.discover_positions, test_filepath) | ||
|
||
it("Mixed case with space", function() | ||
local expected_test_name = '"Mixed case with space"' | ||
local expected_go_test_name = "TestNames/Mixed_case_with_space" | ||
|
||
-- Act | ||
local pos = tree:node(3):data() | ||
local actual_go_test_name = convert.to_gotest_test_name(pos.id) | ||
|
||
-- Assert | ||
local actual_name = pos.name | ||
assert.are.same(expected_test_name, actual_name) | ||
assert.are.same( | ||
vim.inspect(expected_go_test_name), | ||
vim.inspect(actual_go_test_name) | ||
) | ||
end) | ||
|
||
it("Special characters", function() | ||
local expected_test_name = '"Comma , and \' are ok to use"' | ||
local expected_go_test_name = "TestNames/Comma_,_and_'_are_ok_to_use" | ||
|
||
-- Act | ||
local pos = tree:node(4):data() | ||
local actual_go_test_name = convert.to_gotest_test_name(pos.id) | ||
|
||
-- Assert | ||
local actual_name = pos.name | ||
assert.are.same(expected_test_name, actual_name) | ||
assert.are.same( | ||
vim.inspect(expected_go_test_name), | ||
vim.inspect(actual_go_test_name) | ||
) | ||
end) | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
// A dummy test, just to assert that Go tests can run. | ||
func TestNames(t *testing.T) { | ||
t.Run("Mixed case with space", func(t *testing.T) { | ||
if Add(1, 2) != 3 { | ||
t.Fail() | ||
} | ||
}) | ||
|
||
t.Run("Comma , and ' are ok to use", func(t *testing.T) { | ||
if Add(1, 2) != 3 { | ||
t.Fail() | ||
} | ||
}) | ||
} |