Skip to content

Commit 641506f

Browse files
authored
Merge pull request #15 from dubesar/master
Health Check for Node tunnel
2 parents 3f84da5 + 5b4e027 commit 641506f

File tree

3 files changed

+57
-21
lines changed

3 files changed

+57
-21
lines changed

.github/workflows/healthcheck.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Node Tunnel health check
2+
on:
3+
schedule:
4+
- cron: "0 18 * * *"
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
LT_USERNAME: ${{ secrets.LT_USERNAME }}
14+
LT_ACCESS_KEY: ${{ secrets.LT_ACCESS_KEY }}
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Use Node.js 14.x
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 14.x
21+
22+
- name: npm dependencies
23+
run: npm install
24+
25+
- name: Install Mocha
26+
run: npm install -g mocha
27+
28+
- name: Run test
29+
run: npm run test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![LambdaTest Logo](https://www.lambdatest.com/static/images/logo.svg)
22

3-
# LambdaTest Nodejs bindings for Tunnel
3+
# LambdaTest Nodejs bindings for Tunnel
44

55
[![CircleCI](https://circleci.com/gh/LambdaTest/node-tunnel.svg?style=svg)](https://circleci.com/gh/LambdaTest/node-tunnel) [![npm version](https://img.shields.io/npm/v/@lambdatest/node-tunnel.svg?style=flat)](https://www.npmjs.com/package/@lambdatest/node-tunnel 'View this project on npm')
66

tests/test-index.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1+
var lambdaTunnel = require('../index');
12
var chai = require('chai');
23
var expect = chai.expect;
4+
35
describe('Tunnel runs successfully', function() {
6+
var isTunnelStarted = false;
7+
beforeEach(function(done) {
8+
//start tunnel
9+
this.timeout(20000);
10+
var tunnelInstance = new lambdaTunnel();
11+
// replace <lambdatest-user> with your user and <lambdatest-accesskey> with your key.
12+
var tunnelArguments = {
13+
user: process.env.LT_USERNAME || '<lambdatest-user>',
14+
key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>'
15+
};
16+
try {
17+
tunnelInstance.start(tunnelArguments, function(error, status) {
18+
if (!error) {
19+
isTunnelStarted = true;
20+
tunnelInstance.stop().then(status => {
21+
console.log('Tunnel is Stopped ? ' + status);
22+
});
23+
done();
24+
}
25+
});
26+
} catch (error) {
27+
isTunnelStarted = false;
28+
}
29+
});
430
it('Tunnel doesnt start on wrong parameter', function() {
5-
var isTunnelStarted = false;
6-
before(function() {
7-
this.timeout('10sec');
8-
//creates an instance of Tunnel
9-
var tunnelInstance = new lambdaTunnel();
10-
// replace <lambdatest-user> with your user and <lambdatest-accesskey> with your key.
11-
var tunnelArguments = {
12-
user: process.env.LT_USERNAME || '<lambdatest-user>',
13-
key: process.env.LT_ACCESS_KEY || '<lambdatest-accesskey>'
14-
};
15-
try {
16-
tunnelInstance.start(tunnelArguments, function(error, status) {
17-
if (!error) {
18-
isTunnelStarted = true;
19-
}
20-
});
21-
} catch (error) {
22-
isTunnelStarted = false;
23-
}
24-
});
2531
expect(typeof isTunnelStarted).to.equal('boolean');
32+
expect(isTunnelStarted).to.equal(true);
2633
});
2734
});

0 commit comments

Comments
 (0)