Skip to content
This repository was archived by the owner on Sep 24, 2021. It is now read-only.

Commit 6bfd496

Browse files
lggomezramya-rao-a
authored andcommitted
Fix broken tests (microsoft#1538)
* Fix tests * Remove unnecessary coalesce * Change assert messages * Review changes * Restore source path * Revert source path
1 parent 9b6dd0b commit 6bfd496

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/go.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,24 @@ It returns the number of bytes written and any write error encountered.
380380
{ line: 11, severity: 'warning', msg: 'error return value not checked (undeclared name: prin) (errcheck)' },
381381
{ line: 11, severity: 'warning', msg: 'unused variable or constant undeclared name: prin (varcheck)' },
382382
];
383-
return check(vscode.Uri.file(path.join(fixturePath, 'errorsTest', 'errors.go')), config).then(diagnostics => {
383+
let errorsTestPath = path.join(fixtureSourcePath, 'errorsTest', 'errors.go');
384+
return check(vscode.Uri.file(errorsTestPath), config).then(diagnostics => {
384385
let sortedDiagnostics = diagnostics.sort((a, b) => {
385386
if (a.msg < b.msg)
386387
return -1;
387388
if (a.msg > b.msg)
388389
return 1;
389390
return 0;
390391
});
392+
393+
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
394+
391395
for (let i in expected) {
392396
assert.equal(sortedDiagnostics[i].line, expected[i].line, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
393397
assert.equal(sortedDiagnostics[i].severity, expected[i].severity, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
394398
assert.equal(sortedDiagnostics[i].msg, expected[i].msg, `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`);
395399
}
396-
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
400+
397401
return Promise.resolve();
398402
});
399403
}).then(() => done(), done);
@@ -855,22 +859,26 @@ It returns the number of bytes written and any write error encountered.
855859
{ file: path.join(linterTestPath, 'linter_2.go'), line: 5, severity: 'warning', msg: 'error return value not checked (missing return) (errcheck)' },
856860
{ file: path.join(linterTestPath, 'linter_1.go'), line: 5, severity: 'warning', msg: 'exported function ExportedFunc should have comment or be unexported (golint)' },
857861
];
858-
return goLint(vscode.Uri.file(path.join(linterTestPath, 'linter_1.go')), config).then(diagnostics => {
862+
let linterFilePath = path.join(linterTestPath, 'linter_1.go');
863+
return goLint(vscode.Uri.file(linterFilePath), config).then(diagnostics => {
859864
let sortedDiagnostics = diagnostics.sort((a, b) => {
860865
if (a.msg < b.msg)
861866
return -1;
862867
if (a.msg > b.msg)
863868
return 1;
864869
return 0;
865870
});
871+
872+
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
873+
866874
for (let i in expected) {
867875
let errorMsg = `Failed to match expected error #${i}: ${JSON.stringify(sortedDiagnostics)}`;
868876
assert(sortedDiagnostics[i].msg.startsWith(expected[i].msg), errorMsg);
869877
assert.equal(sortedDiagnostics[i].file.toLowerCase(), expected[i].file.toLowerCase(), errorMsg);
870878
assert.equal(sortedDiagnostics[i].line, expected[i].line, errorMsg);
871879
assert.equal(sortedDiagnostics[i].severity, expected[i].severity, errorMsg);
872880
}
873-
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`);
881+
874882
return Promise.resolve();
875883
});
876884
}).then(() => done(), done);

0 commit comments

Comments
 (0)