Skip to content

Commit 1ef871d

Browse files
author
Akos Kitta
committed
fix: platform release version ordering
Signed-off-by: Akos Kitta <[email protected]>
1 parent 41a9be7 commit 1ef871d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Diff for: arduino-ide-extension/src/node/boards-service-impl.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,9 @@ function createBoardsPackage(
589589
return undefined; // never show incompatible platforms
590590
}
591591
const { id, website, maintainer } = summary.metadata;
592+
const availableVersions = Array.from(versionReleaseMap.keys())
593+
.sort(Installable.Version.COMPARATOR)
594+
.reverse();
592595
return {
593596
id,
594597
name,
@@ -602,7 +605,7 @@ function createBoardsPackage(
602605
moreInfoLink: website,
603606
author: maintainer,
604607
deprecated,
605-
availableVersions: Array.from(versionReleaseMap.keys()),
608+
availableVersions,
606609
};
607610
}
608611

Diff for: arduino-ide-extension/src/test/node/boards-service-impl.slow-test.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DisposableCollection } from '@theia/core/lib/common/disposable';
22
import { Container } from '@theia/core/shared/inversify';
33
import { expect } from 'chai';
4-
import { BoardSearch, BoardsService } from '../../common/protocol';
4+
import { BoardSearch, BoardsService, Installable } from '../../common/protocol';
55
import { createBaseContainer, startDaemon } from './node-test-bindings';
66

77
describe('boards-service-impl', () => {
@@ -24,6 +24,29 @@ describe('boards-service-impl', () => {
2424
expect(result).is.not.empty;
2525
});
2626

27+
it('should order the available platform release versions in descending order', async function () {
28+
const result = await boardService.search({});
29+
result.forEach((platform) =>
30+
platform.availableVersions.forEach(
31+
(currentVersion, index, versions) => {
32+
if (index < versions.length - 2) {
33+
const nextArrayElement = versions[index + 1];
34+
const actual = Installable.Version.COMPARATOR(
35+
currentVersion,
36+
nextArrayElement
37+
);
38+
expect(actual).to.be.greaterThan(
39+
0,
40+
`Expected '${currentVersion}' to be gt '${nextArrayElement}'. All versions: ${JSON.stringify(
41+
versions
42+
)}`
43+
);
44+
}
45+
}
46+
)
47+
);
48+
});
49+
2750
it("should boost a result when 'types' includes 'arduino', and lower the score if deprecated", async () => {
2851
const result = await boardService.search({});
2952
const arduinoIndexes: number[] = [];

0 commit comments

Comments
 (0)