Address review comments from @henrymercer
This commit is contained in:
parent
8f867dcb21
commit
6df93613d7
15 changed files with 125 additions and 63 deletions
11
lib/trap-caching.test.js
generated
11
lib/trap-caching.test.js
generated
|
|
@ -74,7 +74,7 @@ const stubCodeql = (0, codeql_1.setCodeQL)({
|
|||
};
|
||||
},
|
||||
});
|
||||
const stubConfig = {
|
||||
const testConfigWithoutTmpDir = {
|
||||
languages: [languages_1.Language.javascript, languages_1.Language.cpp],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
|
|
@ -95,7 +95,7 @@ const stubConfig = {
|
|||
javascript: "/some/cache/dir",
|
||||
},
|
||||
};
|
||||
function getTestConfig(tmpDir) {
|
||||
function getTestConfigWithTempDir(tmpDir) {
|
||||
return {
|
||||
languages: [languages_1.Language.javascript, languages_1.Language.ruby],
|
||||
queries: {},
|
||||
|
|
@ -119,7 +119,7 @@ function getTestConfig(tmpDir) {
|
|||
}
|
||||
(0, ava_1.default)("check flags for JS, analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const result = await (0, trap_caching_1.getTrapCachingExtractorConfigArgsForLang)(config, languages_1.Language.javascript);
|
||||
t.deepEqual(result, [
|
||||
|
|
@ -131,7 +131,7 @@ function getTestConfig(tmpDir) {
|
|||
});
|
||||
(0, ava_1.default)("check flags for all, not analyzing default branch", async (t) => {
|
||||
await util.withTmpDir(async (tmpDir) => {
|
||||
const config = getTestConfig(tmpDir);
|
||||
const config = getTestConfigWithTempDir(tmpDir);
|
||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const result = await (0, trap_caching_1.getTrapCachingExtractorConfigArgs)(config);
|
||||
t.deepEqual(result, [
|
||||
|
|
@ -156,7 +156,7 @@ function getTestConfig(tmpDir) {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||
const stubSave = sinon.stub(cache, "saveCache");
|
||||
process.env.GITHUB_SHA = "somesha";
|
||||
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, stubConfig, logger);
|
||||
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, testConfigWithoutTmpDir, logger);
|
||||
t.assert(stubSave.calledOnceWith(sinon.match.array.contains(["/some/cache/dir"]), sinon
|
||||
.match("somesha")
|
||||
.and(sinon.match("2.10.3"))
|
||||
|
|
@ -170,6 +170,7 @@ function getTestConfig(tmpDir) {
|
|||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||
const stubRestore = sinon.stub(cache, "restoreCache").resolves("found");
|
||||
const eventFile = path.resolve(tmpDir, "event.json");
|
||||
process.env.GITHUB_EVENT_NAME = "pull_request";
|
||||
process.env.GITHUB_EVENT_PATH = eventFile;
|
||||
fs.writeFileSync(eventFile, JSON.stringify({
|
||||
pull_request: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue