MRVA: Also test names of generated markdown files

This commit is contained in:
shati-patel
2022-05-05 10:12:39 +01:00
committed by Shati Patel
parent 6d930f53ba
commit f55389cd26
7 changed files with 26 additions and 33 deletions

View File

@@ -3,6 +3,8 @@ import * as path from 'path';
import * as fs from 'fs-extra';
import { generateMarkdown } from '../../../../src/remote-queries/remote-queries-markdown-generation';
const expectedFileNames = ['summary', 'github-codeql', 'meteor-meteor'];
describe('markdown generation', async function() {
describe('for path-problem query', async function() {
it('should generate markdown file for each repo with results', async function() {
@@ -18,18 +20,15 @@ describe('markdown generation', async function() {
// Check that query has results for two repositories, plus a summary file
expect(markdownFiles.length).to.equal(3);
const markdownFile0 = markdownFiles[0]; // summary file
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
for (let i = 0; i < markdownFiles.length; i++) {
const markdownFile = markdownFiles[i];
const expectedContent = await readTestOutputFile(`data/interpreted-results/path-problem/${expectedFileNames[i]}.md`);
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/path-problem/summary.md');
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo1.md');
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/path-problem/results-repo2.md');
// Check that markdown output is correct, after making line endings consistent
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
// Check that the markdown file has the expected name
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
// Check that the markdown file has the expected content
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
}
});
});
@@ -47,18 +46,15 @@ describe('markdown generation', async function() {
// Check that query has results for two repositories, plus a summary file
expect(markdownFiles.length).to.equal(3);
const markdownFile0 = markdownFiles[0]; // summary file
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
for (let i = 0; i < markdownFiles.length; i++) {
const markdownFile = markdownFiles[i];
const expectedContent = await readTestOutputFile(`data/interpreted-results/problem/${expectedFileNames[i]}.md`);
const expectedSummaryFile = await readTestOutputFile('data/interpreted-results/problem/summary.md');
const expectedTestOutput1 = await readTestOutputFile('data/interpreted-results/problem/results-repo1.md');
const expectedTestOutput2 = await readTestOutputFile('data/interpreted-results/problem/results-repo2.md');
// Check that markdown output is correct, after making line endings consistent
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
// Check that the markdown file has the expected name
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
// Check that the markdown file has the expected content
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
}
});
});
@@ -76,18 +72,15 @@ describe('markdown generation', async function() {
// Check that query has results for two repositories, plus a summary file
expect(markdownFiles.length).to.equal(3);
const markdownFile0 = markdownFiles[0]; // summary file
const markdownFile1 = markdownFiles[1]; // results for github/codeql repo
const markdownFile2 = markdownFiles[2]; // results for meteor/meteor repo
for (let i = 0; i < markdownFiles.length; i++) {
const markdownFile = markdownFiles[i];
const expectedContent = await readTestOutputFile(`data/raw-results/${expectedFileNames[i]}.md`);
const expectedSummaryFile = await readTestOutputFile('data/raw-results/summary.md');
const expectedTestOutput1 = await readTestOutputFile('data/raw-results/results-repo1.md');
const expectedTestOutput2 = await readTestOutputFile('data/raw-results/results-repo2.md');
// Check that markdown output is correct, after making line endings consistent
expect(markdownFile0.content.join('\n')).to.equal(expectedSummaryFile);
expect(markdownFile1.content.join('\n')).to.equal(expectedTestOutput1);
expect(markdownFile2.content.join('\n')).to.equal(expectedTestOutput2);
// Check that the markdown file has the expected name
expect(markdownFile.fileName).to.equal(expectedFileNames[i]);
// Check that the markdown file has the expected content
expect(markdownFile.content.join('\n')).to.equal(expectedContent);
}
});
});
});