Skip to content

Commit

Permalink
fix tests because of reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ninadingole committed Sep 15, 2024
1 parent d8d8ee5 commit 0217e35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestListAllTestsForGivenFile(t *testing.T) {
fmt.Println(buffer.String())

require.JSONEq(t,
strings.ReplaceAll(`[{"name":"BenchmarkSomething","fileName":"benchmark_test.go","relativePath":"tests/benchmark_test.go","absolutePath":"##PATH##/tests/benchmark_test.go","line":5,"pos":44},{"name":"Example_something","fileName":"example_test.go","relativePath":"tests/example_test.go","absolutePath":"##PATH##/tests/example_test.go","line":5,"pos":40},{"name":"Fuzz_Sample","fileName":"fuzz_test.go","relativePath":"tests/fuzz_test.go","absolutePath":"##PATH##/tests/fuzz_test.go","line":5,"pos":39},{"name":"Test/5_+_5_=_10","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":23,"pos":265},{"name":"Test/5_-_5_=_0","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":30,"pos":355},{"name":"Test/mixed_subtest_1","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":12,"pos":111},{"name":"Test/mixed_test_2","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":48,"pos":635},{"name":"TestSomething","fileName":"sample_test.go","relativePath":"tests/sample_test.go","absolutePath":"##PATH##/tests/sample_test.go","line":7,"pos":49},{"name":"Test_subTestPattern/subtest","fileName":"subtest_test.go","relativePath":"tests/subtest_test.go","absolutePath":"##PATH##/tests/subtest_test.go","line":10,"pos":121},{"name":"Test_subTestPattern/subtest_2","fileName":"subtest_test.go","relativePath":"tests/subtest_test.go","absolutePath":"##PATH##/tests/subtest_test.go","line":15,"pos":193}]`,
strings.ReplaceAll(`[{"name":"BenchmarkSomething","fileName":"benchmark_test.go","relativePath":"tests/benchmark_test.go","absolutePath":"##PATH##/tests/benchmark_test.go","line":5,"pos":44},{"name":"Example_something","fileName":"example_test.go","relativePath":"tests/example_test.go","absolutePath":"##PATH##/tests/example_test.go","line":5,"pos":40},{"name":"Fuzz_Sample","fileName":"fuzz_test.go","relativePath":"tests/fuzz_test.go","absolutePath":"##PATH##/tests/fuzz_test.go","line":5,"pos":44},{"name":"Test/5_+_5_=_10","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":23,"pos":265},{"name":"Test/5_-_5_=_0","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":30,"pos":355},{"name":"Test/mixed_subtest_1","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":12,"pos":111},{"name":"Test/mixed_test_2","fileName":"table_test.go","relativePath":"tests/table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":47,"pos":624},{"name":"TestSomething","fileName":"sample_test.go","relativePath":"tests/sample_test.go","absolutePath":"##PATH##/tests/sample_test.go","line":7,"pos":49},{"name":"Test_subTestPattern/subtest","fileName":"subtest_test.go","relativePath":"tests/subtest_test.go","absolutePath":"##PATH##/tests/subtest_test.go","line":10,"pos":121},{"name":"Test_subTestPattern/subtest_2","fileName":"subtest_test.go","relativePath":"tests/subtest_test.go","absolutePath":"##PATH##/tests/subtest_test.go","line":15,"pos":193}]`,
"##PATH##", pwd),
buffer.String())
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func Test_process(t *testing.T) {
checks: func(t *testing.T, got string) {
t.Helper()

require.JSONEq(t, strings.ReplaceAll(`[{"name":"Test/5_+_5_=_10","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":23,"pos":265},{"name":"Test/5_-_5_=_0","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":30,"pos":355},{"name":"Test/mixed_subtest_1","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":12,"pos":111},{"name":"Test/mixed_test_2","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":48,"pos":635}]`, "##PATH##", pwd), got)
require.JSONEq(t, strings.ReplaceAll(`[{"name":"Test/5_+_5_=_10","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":23,"pos":265},{"name":"Test/5_-_5_=_0","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":30,"pos":355},{"name":"Test/mixed_subtest_1","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":12,"pos":111},{"name":"Test/mixed_test_2","fileName":"table_test.go","relativePath":"table_test.go","absolutePath":"##PATH##/tests/table_test.go","line":47,"pos":624}]`, "##PATH##", pwd), got)
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func listTests(files map[string][]string) ([]TestDetail, error) { //nolint: goco
for _, testFile := range testFiles {
set := token.NewFileSet()

parseFile, err := parser.ParseFile(set, testFile, nil, parser.AllErrors)
parseFile, err := parser.ParseFile(set, testFile, nil, parser.SkipObjectResolution)
if err != nil {
return nil, err
}
Expand Down
18 changes: 8 additions & 10 deletions pkg/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func Test_List(t *testing.T) {
RelativePath: "fuzz_test.go",
AbsolutePath: parentDir + "/tests/fuzz_test.go",
Line: 5,
Pos: 39,
Pos: 44,
},
},
},
Expand Down Expand Up @@ -119,9 +119,7 @@ dummy dummy test
require.NoError(t, err)

//nolint:gosec
err = os.WriteFile(dir+"/sample/sample_test.go", []byte(`
package tests_test
err = os.WriteFile(dir+"/sample/sample_test.go", []byte(`package tests_test
import (
"testing"
Expand All @@ -146,33 +144,33 @@ var (
Name: "Test/5_+_5_=_10",
FileName: "table_test.go",
RelativePath: "table_test.go",
AbsolutePath: parentDir + "%s/tests/table_test.go",
AbsolutePath: parentDir + "/tests/table_test.go",
Line: 23,
Pos: 265,
},
{
Name: "Test/5_-_5_=_0",
FileName: "table_test.go",
RelativePath: "table_test.go",
AbsolutePath: parentDir + "%s/tests/table_test.go",
AbsolutePath: parentDir + "/tests/table_test.go",
Line: 30,
Pos: 355,
},
{
Name: "Test/mixed_subtest_1",
FileName: "table_test.go",
RelativePath: "table_test.go",
AbsolutePath: parentDir + "%s/tests/table_test.go",
AbsolutePath: parentDir + "/tests/table_test.go",
Line: 12,
Pos: 111,
},
{
Name: "Test/mixed_test_2",
FileName: "table_test.go",
RelativePath: "table_test.go",
AbsolutePath: parentDir + "%s/tests/table_test.go",
Line: 48,
Pos: 635,
AbsolutePath: parentDir + "/tests/table_test.go",
Line: 47,
Pos: 624,
},
}
)

0 comments on commit 0217e35

Please sign in to comment.