-
Notifications
You must be signed in to change notification settings - Fork 646
Fix #656 "gotests" when generates test for current function #657
Fix #656 "gotests" when generates test for current function #657
Conversation
ecc9613
to
da19d3d
Compare
if (funcName.includes('.')) { | ||
funcName = funcName.split('.')[1]; | ||
} | ||
generateTests({ dir: file, func: funcName }).then((success: boolean) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a new promise at line 92. The below will do
return getFunctions(editor.document).then(functions => {
...
...
return generateTests({dir: file, fun: funcName});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks
import { getBinPath } from '../src/goPath'; | ||
|
||
suite('Go Extension Tests', () => { | ||
let gopath = process.env['GOPATH']; | ||
let repoPath = path.join(gopath, 'src', 'test'); | ||
let fixturePath = path.join(repoPath, 'testfixture'); | ||
let fixtureSourcePath = path.join(__dirname, '..', '..', 'test', 'fixtures'); | ||
let generateTestsSourcePath = path.join(repoPath, 'generatetests'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just re-use fixturePath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the tests use the same file, 2 tests will failed, since the all tests will be already generated by the "generate test in current package"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
let selection = new vscode.Selection(5, 0, 6, 0); | ||
editor.selection = selection; | ||
return generateTestCurrentFunction().then((result: boolean) => { | ||
assert.equal(result, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, I'd like to check whether the test file was created with the test function. You don't have do it now, but if you have some time, I'd appreciate it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea and done.
da19d3d
to
1287b1f
Compare
@@ -9,4 +9,4 @@ func print(txt string) { | |||
} | |||
func main() { | |||
print("Hello") | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removal of this line at the end is breaking one of the tests which tries to add some text there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test updated
83825f2
to
6f2cfb4
Compare
Issue: "Generate unit tests for current function" fails with recent vscode-go version. This due to the fact that the GoDocumentSymbolProvider returns now also the receiverType in the name function. example: before "DecodeJSON", after (*Volume).DecodeJSON gotests bin is not able to understand this string with the option -only since it is not a valid regular expression. Fixes: microsoft#656 check is the function name contains a ".", if yes: returns only the second part of the name that is corresponding to the function name without the receiverType.
6f2cfb4
to
db88638
Compare
@ramya-rao-a thanks for your quick review ! |
My pleasure @cedriclam. Thanks for your contributions. Looking forward for more in areas other than generate tests as well :) |
* 'master' of github.com:mattetti/vscode-go: (128 commits) Add telemetry support for the Go extension Add dlv path to error msg when dlv not found Fixes microsoft#465 outline offset problem in No-English language (microsoft#699) fix coverage display when editor changes to undefined (microsoft#693) Add support for reading http.proxy setting (microsoft#639) Fixing flaky unit tests Refactor for corner cases Reduce noise in console log due to errors from hover Changelog for next update 0.6.51 Remove space after brackets in snippet as per microsoft#628 Fixes microsoft#647 Strip version from autocompleted pkgs from gopkg.in (microsoft#659) Fixes microsoft#647 Support vendor pkgs from root of GOPATH/src (microsoft#660) Fixes microsoft#640 Use spawn to handle big data from gocode (microsoft#661) Fixed wrong workspace when one gopath is the substring of another. (microsoft#658) Fix "gotests" when generates test for current function for type methods (microsoft#657) Add benchmark function snippet (microsoft#648) Fix "Go to Definition" when running Go HEAD (microsoft#655) Fixes microsoft#642 Only add -d once to formatflags (microsoft#644) Updating Changelog and package.json for 0.6.50 update Log errors to console ...
Issue:
"Generate unit tests for current function" fails with recent
vscode-go version. This due to the fact that the GoDocumentSymbolProvider
returns now also the receiverType in the name function.
example: before "DecodeJSON", after (*Volume).DecodeJSON
gotests bin is not able to understand this string with the option -only
since it is not a valid regular expression.
Fixes: #656
check is the function name contains a ".", if yes: returns only the
second part of the name that is corresponding to the function name
without the receiverType.