-
Notifications
You must be signed in to change notification settings - Fork 645
Considering receiverType on function test creation issue-2282 #2987
Conversation
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.
Looks like this is your first PR contribution to this project @marcel-basel, Thanks & Welcome!
src/goGenerateTests.ts
Outdated
if (funcName.includes('.')) { | ||
funcName = funcName.split('.')[1]; | ||
if (funcName.includes('.')) { // receiverType specified | ||
let funcNameParts = funcName.match(/^\(\*?(.*)\)\.(.*)$/); |
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 we are going to use a regular expression, then the if (funcName.includes('.'))
check is redundant right?
Do we foresee the function name to include .
in a non receiverType case?
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.
Hi Ramya, thanks for your fantastic work on the extension!
I removed the if (funcName.includes('.'))
block. I don't see an other case where the function name would include .
Do you?
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.
Nope, change looks good. I have pushed a commit to fix the linting errors, we are good to merge now
Thanks @ramya-rao-a, do you consider #2282 as closable? |
I'll be closing it once I release an update with the fix. |
The receiver type for a method is now considered. So, if there are >= 1 method names in the same file, then clicking "generate unit tests for function" creates test functions only for the selected method.
funcName like "(*Point).Move" will results in "gotests -w -only ^PointMove$ calls.