From 32aa034152b365997b92512438c12bb3c900a792 Mon Sep 17 00:00:00 2001 From: Ramya Achutha Rao Date: Wed, 16 Nov 2016 22:47:17 -0800 Subject: [PATCH] fix tests --- test/go.test.ts | 89 ++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/test/go.test.ts b/test/go.test.ts index f52fc38ce..f720a8a9d 100644 --- a/test/go.test.ts +++ b/test/go.test.ts @@ -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); - }); @@ -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, (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, (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); }); @@ -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); }); @@ -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' } }