Considering receiverType on function test creation issue-2282 (#2987)
diff --git a/src/goGenerateTests.ts b/src/goGenerateTests.ts
index 7e8df75..1fbd717 100644
--- a/src/goGenerateTests.ts
+++ b/src/goGenerateTests.ts
@@ -98,9 +98,13 @@
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));
}