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

Open test file after the Generate Unit Tests command #610

Merged
merged 1 commit into from
Nov 9, 2016
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
20 changes: 5 additions & 15 deletions src/goGenerateTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { promptForMissingTool } from './goInstallTools';
import { GoDocumentSymbolProvider } from './goOutline';

const generatedWord = 'Generated ';
const commandTitle = 'Open generated test for current file';

/**
* If current active editor has a Go file, returns the editor.
Expand Down Expand Up @@ -78,7 +77,7 @@ export function generateTestCurrentPackage(): Thenable<boolean> {
}
let dir = path.dirname(editor.document.uri.fsPath);
let message = 'Unit tests generated for package: ' + path.basename(dir);
return generateTests({ dir: dir, msg: message });
return generateTests({ dir: dir });
}

export function generateTestCurrentFile(): Thenable<boolean> {
Expand All @@ -88,7 +87,7 @@ export function generateTestCurrentFile(): Thenable<boolean> {
}
let file = editor.document.uri.fsPath;
let message = 'Unit tests generated for file: ' + path.basename(file);
return generateTests({ dir: file, msg: message });
return generateTests({ dir: file });
}

export function generateTestCurrentFunction(): Thenable<boolean> {
Expand All @@ -111,7 +110,7 @@ export function generateTestCurrentFunction(): Thenable<boolean> {
return;
}
let message = 'Unit test generated for function: ' + currentFunction.name + ' in file: ' + path.basename(file);
return generateTests({ dir: file, msg: message, func: currentFunction.name });
return generateTests({ dir: file, func: currentFunction.name });
}).then(null, err => {
console.error(err);
});
Expand All @@ -125,10 +124,6 @@ interface Config {
* The working directory for `gotests`.
*/
dir: string;
/**
* The Message that show up in case of success
*/
msg: string;
/**
* Specific function names to generate tests squeleton.
*/
Expand Down Expand Up @@ -168,14 +163,9 @@ function generateTests(conf: Config): Thenable<boolean> {
testsGenerated = true;
}

vscode.window.showInformationMessage(message);
if (testsGenerated) {
vscode.window.showInformationMessage(message, commandTitle).then(selected => {
if (selected === commandTitle) {
openTestFile();
}
});
} else {
vscode.window.showInformationMessage(message);
openTestFile();
}

return resolve(true);
Expand Down