Skip to content

Commit f55389c

Browse files
committed
MRVA: Also test names of generated markdown files
1 parent 6d930f5 commit f55389c

7 files changed

Lines changed: 26 additions & 33 deletions

File tree

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/results-repo1.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/github-codeql.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/results-repo2.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/path-problem/meteor-meteor.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/problem/results-repo1.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/problem/github-codeql.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/problem/results-repo2.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/interpreted-results/problem/meteor-meteor.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/raw-results/results-repo1.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/raw-results/github-codeql.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/raw-results/results-repo2.md renamed to extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/data/raw-results/meteor-meteor.md

File renamed without changes.

extensions/ql-vscode/test/pure-tests/remote-queries/markdown-generation/markdown-generation.test.ts

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import * as path from 'path';
33
import * as fs from 'fs-extra';
44
import { generateMarkdown } from '../../../../src/remote-queries/remote-queries-markdown-generation';
55

6+
const expectedFileNames = ['summary', 'github-codeql', 'meteor-meteor'];
7+
68
describe('markdown generation', async function() {
79
describe('for path-problem query', async function() {
810
it('should generate markdown file for each repo with results', async function() {
@@ -18,18 +20,15 @@ describe('markdown generation', async function() {
1820
// Check that query has results for two repositories, plus a summary file
1921
expect(markdownFiles.length).to.equal(3);
2022

21-
const markdownFile0 = markdownFiles[0]; // summary file
22-
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
23-
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
24-
25-
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
26-
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
27-
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
23+
for (let i = 0; i < markdownFiles.length; i++) {
24+
const markdownFile = markdownFiles[i];
25+
const expectedContent = await readTestOutputFile(`data/interpreted-results/path-problem/${expectedFileNames[i]}.md`);
2826

29-
// Check that markdown output is correct, after making line endings consistent
30-
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
31-
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
32-
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
27+
// Check that the markdown file has the expected name
28+
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
29+
// Check that the markdown file has the expected content
30+
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
31+
}
3332
});
3433
});
3534

@@ -47,18 +46,15 @@ describe('markdown generation', async function() {
4746
// Check that query has results for two repositories, plus a summary file
4847
expect(markdownFiles.length).to.equal(3);
4948

50-
const markdownFile0 = markdownFiles[0]; // summary file
51-
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
52-
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
49+
for (let i = 0; i < markdownFiles.length; i++) {
50+
const markdownFile = markdownFiles[i];
51+
const expectedContent = await readTestOutputFile(`data/interpreted-results/problem/${expectedFileNames[i]}.md`);
5352

54-
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
55-
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
56-
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
57-
58-
// Check that markdown output is correct, after making line endings consistent
59-
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
60-
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
61-
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
53+
// Check that the markdown file has the expected name
54+
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
55+
// Check that the markdown file has the expected content
56+
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
57+
}
6258
});
6359
});
6460

@@ -76,18 +72,15 @@ describe('markdown generation', async function() {
7672
// Check that query has results for two repositories, plus a summary file
7773
expect(markdownFiles.length).to.equal(3);
7874

79-
const markdownFile0 = markdownFiles[0]; // summary file
80-
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
81-
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
82-
83-
const expectedSummaryFile = await readTestOutputFile('data/raw-results/summary.md');
84-
const expectedTestOutput1 = await readTestOutputFile('data/raw-results/results-repo1.md');
85-
const expectedTestOutput2 = await readTestOutputFile('data/raw-results/results-repo2.md');
75+
for (let i = 0; i < markdownFiles.length; i++) {
76+
const markdownFile = markdownFiles[i];
77+
const expectedContent = await readTestOutputFile(`data/raw-results/${expectedFileNames[i]}.md`);
8678

87-
// Check that markdown output is correct, after making line endings consistent
88-
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
89-
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
90-
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
79+
// Check that the markdown file has the expected name
80+
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
81+
// Check that the markdown file has the expected content
82+
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
83+
}
9184
});
9285
});
9386
});

0 commit comments

Comments
 (0)