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

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Nov 17, 2016
1 parent aa102a8 commit 32aa034
Showing 1 changed file with 47 additions and 42 deletions.
89 changes: 47 additions & 42 deletions test/go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ suite('Go Extension Tests', () => {
let provider = new GoDefinitionProvider();
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go'));
let position = new vscode.Position(10, 3);
vscode.workspace.openTextDocument(uri).then((textDocument) => {
return provider.provideDefinition(textDocument, position, null).then(definitionInfo => {
assert.equal(definitionInfo.uri.path, uri.path, `${definitionInfo.uri.path} is not the same as ${uri.path}`);
vscode.workspace.getConfiguration('go').update('docsTool', 'gogetdoc', true).then(result => {
return vscode.workspace.openTextDocument(uri).then((textDocument) => {
return provider.provideDefinition(textDocument, position, null).then(definitionInfo => {
assert.equal(definitionInfo.uri.path, uri.path, `${definitionInfo.uri.path} is not the same as ${uri.path}`);
});
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
});
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
}).then(() => done(), done);

});


Expand All @@ -76,30 +77,32 @@ encountered.
];
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go'));

getGoVersion().then(version => {
if (version.major > 1 || (version.major === 1 && version.minor > 5)) {
testCases[0][1] = 'func main()';
testCases[1][1] = 'package fmt';
testCases[2][1] = 'func Println(a ...interface{}) (n int, err error)';
testCases[3][1] = 'func print(txt string)';
}
return vscode.workspace.openTextDocument(uri).then((textDocument) => {
let promises = testCases.map(([position, expectedSignature, expectedDocumentation]) =>
provider.provideHover(textDocument, position, null).then(res => {
// TODO: Documentation appears to currently be broken on Go 1.7, so disabling these tests for now
// if (expectedDocumentation === null) {
// assert.equal(res.contents.length, 1);
// } else {
// assert.equal(res.contents.length, 2);
// assert.equal(expectedDocumentation, <string>(res.contents[0]));
// }
assert.equal(expectedSignature, (<{ language: string; value: string }>res.contents[0]).value);
})
);
return Promise.all(promises);
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
return Promise.reject(err);
vscode.workspace.getConfiguration('go').update('docsTool', 'gogetdoc', true).then(result => {
return getGoVersion().then(version => {
if (version.major > 1 || (version.major === 1 && version.minor > 5)) {
testCases[0][1] = 'func main()';
testCases[1][1] = 'package fmt';
testCases[2][1] = 'func Println(a ...interface{}) (n int, err error)';
testCases[3][1] = 'func print(txt string)';
}
return vscode.workspace.openTextDocument(uri).then((textDocument) => {
let promises = testCases.map(([position, expectedSignature, expectedDocumentation]) =>
provider.provideHover(textDocument, position, null).then(res => {
// TODO: Documentation appears to currently be broken on Go 1.7, so disabling these tests for now
// if (expectedDocumentation === null) {
// assert.equal(res.contents.length, 1);
// } else {
// assert.equal(res.contents.length, 2);
// assert.equal(expectedDocumentation, <string>(res.contents[0]));
// }
assert.equal(expectedSignature, (<{ language: string; value: string }>res.contents[0]).value);
})
);
return Promise.all(promises);
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
return Promise.reject(err);
});
});
}).then(() => done(), done);
});
Expand Down Expand Up @@ -179,16 +182,18 @@ encountered.
[new vscode.Position(10, 7), 'print(txt string)']
];
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go'));
vscode.workspace.openTextDocument(uri).then((textDocument) => {
let promises = testCases.map(([position, expected]) =>
provider.provideSignatureHelp(textDocument, position, null).then(sigHelp => {
assert.equal(sigHelp.signatures.length, 1, 'unexpected number of overloads');
assert.equal(sigHelp.signatures[0].label, expected);
})
);
return Promise.all(promises);
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
vscode.workspace.getConfiguration('go').update('docsTool', 'gogetdoc', true).then(result => {
return vscode.workspace.openTextDocument(uri).then((textDocument) => {
let promises = testCases.map(([position, expected]) =>
provider.provideSignatureHelp(textDocument, position, null).then(sigHelp => {
assert.equal(sigHelp.signatures.length, 1, 'unexpected number of overloads');
assert.equal(sigHelp.signatures[0].label, expected);
})
);
return Promise.all(promises);
}, (err) => {
assert.ok(false, `error in OpenTextDocument ${err}`);
});
}).then(() => done(), done);
});

Expand Down Expand Up @@ -388,8 +393,8 @@ encountered.
});
});

// This test is failing in Travis for Mac OS X with Go 1.7.
// Commenting this and created issue https://github.com/Microsoft/vscode-go/issues/609 to track the problem
// This test is failing in Travis for Mac OS X with Go 1.7.
// Commenting this and created issue https://github.com/Microsoft/vscode-go/issues/609 to track the problem
// test('Test Env Variables are passed to Tests', (done) => {
// let config = Object.create(vscode.workspace.getConfiguration('go'), {
// 'testEnvVars': { value: { 'dummyEnvVar': 'dummyEnvValue' } }
Expand Down

0 comments on commit 32aa034

Please sign in to comment.