Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test behaviour for 2.8.12.2 #51

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
cmake_ver: ['', '3.19.3', '3.15.1', '2.8']
cmake_ver: ['', '3.19.3', '3.15.1', '2.8', '2.8.12.1', '2.8.12.2']

steps:
- name: Checkout
Expand Down
10 changes: 10 additions & 0 deletions __tests__/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ describe('Pulling from multipage results with Link header', () => {
const selected = version.getLatestMatching('2.8.10', version_info);
expect(selected.name).toMatch(/2.8.10/);
});
it('selects the correct version for 2.8.12.2', async () => {
const version_info = await version.getAllVersionInfo();
const selected = version.getLatestMatching('2.8.12.2', version_info);
expect(selected.name).toMatch(/2.8.12.2/);
});
it('selects the correct version for 2.8.12', async () => {
const version_info = await version.getAllVersionInfo();
const selected = version.getLatestMatching('2.8.12', version_info);
expect(selected.name).toMatch(/2.8.12/);
});
});

describe('Pulling from multipage results without Link header', () => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package-lock.json

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

6 changes: 6 additions & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,19 @@ function getLatest(version_list: vi.VersionInfo[]): vi.VersionInfo {
return sorted_versions[0];
}

function getVersionListString(version_list: vi.VersionInfo[]): String {
return JSON.stringify(version_list.map((v) => v.name));
}

export function getLatestMatching(
version: string,
version_list: vi.VersionInfo[]
): vi.VersionInfo {
core.debug(`Searching for ${version} in ${getVersionListString(version_list)}`);
let matching_versions = version_list
.filter((v) => !v.draft && !v.prerelease)
.filter((v) => semver.satisfies(v.name, version));
core.debug(`Found ${getVersionListString(matching_versions)}`);
if (matching_versions.length == 0) {
throw new Error('Unable to find version matching ' + version);
}
Expand Down