Skip to content

Commit

Permalink
feat: add protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
shixia.ly committed Oct 18, 2024
1 parent efac8a9 commit 1e09aa6
Show file tree
Hide file tree
Showing 3 changed files with 14,237 additions and 0 deletions.
7 changes: 7 additions & 0 deletions config/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ const binaries = {
repo: 'samizdatco/skia-canvas',
distUrl: 'https://github.com/samizdatco/skia-canvas/releases',
},
'protobuf': {

Check failure on line 141 in config/binaries.ts

View workflow job for this annotation

GitHub Actions / test-mysql57-fs-nfs (18, ubuntu-latest)

Unnecessarily quoted property 'protobuf' found

Check failure on line 141 in config/binaries.ts

View workflow job for this annotation

GitHub Actions / test-mysql57-fs-nfs (20, ubuntu-latest)

Unnecessarily quoted property 'protobuf' found

Check failure on line 141 in config/binaries.ts

View workflow job for this annotation

GitHub Actions / test-mysql57-fs-nfs (22, ubuntu-latest)

Unnecessarily quoted property 'protobuf' found
category: 'protobuf',
description: 'Protocol Buffers - Google\'s data interchange format',
type: BinaryType.GitHub,
repo: 'protocolbuffers/protobuf',
distUrl: 'https://github.com/protocolbuffers/protobuf/releases',
},
wrtc: {
category: 'wrtc',
description: 'node-webrtc is a Node.js Native Addon that provides bindings to WebRTC M87.',
Expand Down
38 changes: 38 additions & 0 deletions test/common/adapter/binary/GithubBinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,43 @@ describe('test/common/adapter/binary/GithubBinary.test.ts', () => {
assert(matchFile2);
assert(matchFile3);
});

it('should fetch protobuf', async () => {
const response = await TestUtil.readJSONFile(TestUtil.getFixtures('protobuf-releases.json'));
app.mockHttpclient(/https:\/\/api\.github\.com\/repos\/protocolbuffers\/protobuf\/releases/, 'GET', {
data: response,
status: 200,
});
let result = await binary.fetch('/', 'protobuf');
assert(result);
assert(result.items.length > 0);
let matchDir = false;
for (const item of result.items) {
assert(item.isDir === true);
if (item.name === 'v28.2/') {
matchDir = true;
}
}
assert(matchDir);

result = await binary.fetch('/v28.2/', 'protobuf');
assert(result?.items.every(item => !/{.*}/.test(item.url)));

result = await binary.fetch('/v28.2/', 'protobuf');
assert(result);
assert(result.items.length > 0);
console.log(JSON.stringify(result.items, null, 2));
let matchFile1 = false;
for (const item of result.items) {
assert(item.isDir === false);
if (item.name === 'protoc-28.2-linux-aarch_64.zip') {
assert(item.date === '2024-09-18T21:02:40Z');
assert(item.size === 3218760);
assert.equal(item.url, 'https://github.com/protocolbuffers/protobuf/releases/download/v28.2/protoc-28.2-linux-aarch_64.zip');
matchFile1 = true;
}
}
assert(matchFile1);
});
});
});
Loading

0 comments on commit 1e09aa6

Please sign in to comment.