Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Considering receiverType on function test creation issue-2282 #2987

Merged
merged 4 commits into from
Jan 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/goGenerateTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ export async function generateTestCurrentFunction(): Promise<boolean> {
return Promise.resolve(false);
}
let funcName = currentFunction.name;
if (funcName.includes('.')) {
funcName = funcName.split('.')[1];
const funcNameParts = funcName.match(/^\(\*?(.*)\)\.(.*)$/);
if (funcNameParts != null && funcNameParts.length === 3) { // receiver type specified
const rType = funcNameParts[1].replace(/^\w/, (c) => c.toUpperCase());
const fName = funcNameParts[2].replace(/^\w/, (c) => c.toUpperCase());
funcName = rType + fName;
}

return generateTests({ dir: editor.document.uri.fsPath, func: funcName }, getGoConfig(editor.document.uri));
}

Expand Down