Skip to content

Commit

Permalink
Fix TestMain redeclaration error
Browse files Browse the repository at this point in the history
  • Loading branch information
polinasok committed May 18, 2022
1 parent 6e9b259 commit 650fb12
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
17 changes: 17 additions & 0 deletions test/integration/codelens.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,21 @@ suite('Code lenses for testing and benchmarking', function () {
// Results should match `go test -list`.
assert.deepStrictEqual(found, ['Fuzz', 'FuzzFunc', 'TestGo118']);
});

test('Test codelenses skip TestMain', async () => {
const uri = vscode.Uri.file(path.join(fixturePath, 'testmain/testmain_test.go'));
const testDocument = await vscode.workspace.openTextDocument(uri);
const codeLenses = await codeLensProvider.provideCodeLenses(testDocument, cancellationTokenSource.token);
assert.equal(codeLenses.length, 4, JSON.stringify(codeLenses, null, 2));
const found = [] as string[];
for (let i = 0; i < codeLenses.length; i++) {
const lens = codeLenses[i];
if (lens.command.command === 'go.test.cursor') {
found.push(lens.command.arguments[0].functionName);
}
}
found.sort();
// Results should match `go test -list`.
assert.deepStrictEqual(found, ['TestNotMain']);
});
});
3 changes: 0 additions & 3 deletions test/testdata/codelens/codelens_go118_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ func Fuzz(f *testing.F) {

func TestGo118(t *testing.T) {
}

func TestMain(m *testing.M) {
}
11 changes: 11 additions & 0 deletions test/testdata/codelens/testmain/testmain_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"testing"
)

func TestNotMain(t *testing.T) {
}

func TestMain(m *testing.M) {
}

0 comments on commit 650fb12

Please sign in to comment.