Skip to content

Commit e9a4344

Browse files
author
Paul Johnston
committed
Merge branch 'master' of github.com:stackb/bzl-sdk-node
2 parents 37c30db + 236022a commit e9a4344

6 files changed

Lines changed: 4784 additions & 3556 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [10.x, 12.x, 14.x]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm ci
28+
- run: npm run build --if-present
29+
- run: npm test

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ const pb = require('./build/stack/bzl/v1beta1/application_pb');
33
const grpc_pb = require('./build/stack/bzl/v1beta1/application_grpc_pb');
44

55
module.exports = {
6-
v1beta1: Object.assign(pb, grpc_pb),
6+
v1beta1: Object.assign({}, pb, grpc_pb),
77
};

index.test.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ const v1beta1 = bzl.v1beta1;
66
// console.log('v1beta1', v1beta1);
77

88

9-
function newInsecureClient(address) {
10-
return new grpc.Client(address, grpc.credentials.createInsecure());
11-
}
12-
139
function newApplicationClient(address) {
1410
return new v1beta1.ApplicationClient(address, grpc.credentials.createInsecure());
1511
}
@@ -21,21 +17,33 @@ test('require() dependencies are satisfied', () => {
2117

2218
// this test is skipped as it currently requires a bzl instance to be running
2319
test.skip('connects', done => {
24-
try {
25-
const client = newApplicationClient('localhost:1080');
26-
client.waitForReady(4000, () => {
27-
client.getApplicationMetadata(
28-
new v1beta1.GetApplicationMetadataRequest(),
29-
(err, metadata) => {
30-
expect(err).toBeNull();
31-
expect(metadata).toBeDefined();
32-
expect(metadata.getName()).toBe('bzl');
33-
done();
34-
}
35-
)
36-
});
37-
} catch (err) {
38-
done(err);
39-
}
20+
const client = newApplicationClient('localhost:1080');
21+
client.waitForReady(withTimeoutSeconds(3), (err) => {
22+
if (err) {
23+
throw err;
24+
}
25+
console.log(`OK, seems ready`);
26+
try {
27+
28+
const request = new v1beta1.GetApplicationMetadataRequest();
29+
client.getApplicationMetadata(request, (err, metadata) => {
30+
expect(err).toBeNull();
31+
expect(metadata).toBeDefined();
32+
expect(metadata.getName()).toBe('bzl');
33+
expect(metadata.getVersion()).toBe('snapshot');
34+
done();
35+
});
36+
} catch (err) {
37+
done(err);
38+
} finally {
39+
// client.close();
40+
}
41+
});
42+
4043
});
4144

45+
function withTimeoutSeconds(seconds) {
46+
const deadline = new Date();
47+
deadline.setSeconds(deadline.getSeconds() + seconds);
48+
return deadline;
49+
}

0 commit comments

Comments
 (0)