Skip to content

Commit

Permalink
Move formatGitHubVersion into util.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Apr 28, 2022
1 parent 5227afa commit 35ef6a2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 31 deletions.
15 changes: 1 addition & 14 deletions lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion lib/util.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.test.js.map

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ test("isGitHubGhesVersionBelow", async (t) => {
);
});

function formatGitHubVersion(version: util.GitHubVersion): string {
switch (version.type) {
case util.GitHubVariant.DOTCOM:
return "dotcom";
case util.GitHubVariant.GHAE:
return "GHAE";
case util.GitHubVariant.GHES:
return `GHES ${version.version}`;
default:
util.assertNever(version);
}
}

const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> =
[
["1.2.1", { type: util.GitHubVariant.DOTCOM }, true],
Expand All @@ -416,7 +429,7 @@ for (const [
const reportWarningDescription = shouldReportWarning
? "reports warning"
: "doesn't report warning";
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${util.formatGitHubVersion(
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(
githubVersion
)}`;
test(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
Expand Down
13 changes: 0 additions & 13 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,3 @@ export async function checkActionVersion(version: string) {
}
}
}

export function formatGitHubVersion(version: GitHubVersion): string {
switch (version.type) {
case GitHubVariant.DOTCOM:
return "dotcom";
case GitHubVariant.GHAE:
return "GHAE";
case GitHubVariant.GHES:
return `GHES ${version.version}`;
default:
assertNever(version);
}
}

0 comments on commit 35ef6a2

Please sign in to comment.