Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add test
  • Loading branch information
esbena committed Oct 28, 2021
commit 91e3c857abf66fbd599732edecadde3999a5af76
74 changes: 72 additions & 2 deletions src/config-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ test("No detected languages", async (t) => {
});
});

test("Unknown languages", async (t) => {
test("Unknown, unsupported languages", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const languages = "rubbish,english";

Expand All @@ -998,7 +998,77 @@ test("Unknown languages", async (t) => {
} catch (err) {
t.deepEqual(
err,
new Error(configUtils.getUnsupportedLanguagesError(["rubbish", "english"]))
new Error(
configUtils.getUnsupportedLanguagesError(["rubbish", "english"])
)
);
}
});
});

test("Unknown, supported languages", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const languages = "ql";

const codeQL = setCodeQL({
async resolveLanguages() {
return {
ql: ["/tmp/ql-for-ql-pack"],
};
},
});

let config: configUtils.Config = await configUtils.initConfig(
languages,
undefined,
undefined,
undefined,
undefined,
{ owner: "github", repo: "example " },
tmpDir,
tmpDir,
codeQL,
tmpDir,
gitHubVersion,
sampleApiDetails,
getRunnerLogger(true)
);
t.deepEqual(config.languages, ["ql"]);
});
});

test("Partially supported languages", async (t) => {
return await util.withTmpDir(async (tmpDir) => {
const languages = "rubbish,ql";

const codeQL = setCodeQL({
async resolveLanguages() {
return {
ql: ["/tmp/ql-for-ql-pack"],
};
},
});
try {
await configUtils.initConfig(
languages,
undefined,
undefined,
undefined,
undefined,
{ owner: "github", repo: "example " },
tmpDir,
tmpDir,
codeQL,
tmpDir,
gitHubVersion,
sampleApiDetails,
getRunnerLogger(true)
);
throw new Error("initConfig did not throw error");
} catch (err) {
t.deepEqual(
err,
new Error(configUtils.getUnsupportedLanguagesError(["rubbish"]))
);
}
});
Expand Down