@getgauge/cli
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -35,3 +35,3 @@ { | ||
}, | ||
"version": "1.0.5" | ||
"version": "1.0.6" | ||
} |
@@ -46,2 +46,5 @@ #!/usr/bin/env node | ||
try { | ||
if( err ) reject(new Error(err)); | ||
if ( res && res.statusCode >= 400 ) reject(new Error (res.body.message)); | ||
if (!data.assets) reject(new Error('Please check your internet connection. Also ensure that you are not behind any firewall.')) | ||
for (const key in data.assets) { | ||
@@ -48,0 +51,0 @@ if (data.assets.hasOwnProperty(key)) { |
"use strict" | ||
const expect = require('chai').expect, | ||
const expect = require('chai').expect, | ||
fs = require('fs'), | ||
@@ -30,2 +30,5 @@ sinon = require('sinon'), | ||
describe("getBinaryMeta", () => { | ||
afterEach(() => { | ||
request.get.restore(); | ||
}); | ||
it("should fetch platform specific metadata", async () => { | ||
@@ -62,3 +65,3 @@ let url = subject.getReleaseURL(); | ||
Object.defineProperty(process, 'arch', { value: "ia32" }); | ||
expect(await subject.getBinaryUrl()).equals("https://github.com/getgauge/gauge/releases/download/v1.0.0/gauge-1.0.0-windows.x86.zip"); | ||
@@ -69,4 +72,28 @@ | ||
}); | ||
it("should return error message", async () => { | ||
let url = subject.getReleaseURL(); | ||
sinon.stub(request, 'get').yields("error message", undefined, undefined); | ||
try { | ||
await subject.getBinaryUrl(); | ||
} catch (err) { | ||
expect(err.message).equals("error message"); | ||
} | ||
}); | ||
it("should return rate limit exceeded message", async () => { | ||
let url = subject.getReleaseURL(); | ||
let response = { | ||
statusCode: 403, | ||
body:{message:'API rate limit exceeded for 12.160.108.130'} | ||
} | ||
sinon.stub(request, 'get').yields(undefined, response, undefined); | ||
try { | ||
await subject.getBinaryUrl(); | ||
} catch (err) { | ||
expect(err.message).equals("API rate limit exceeded for 12.160.108.130"); | ||
} | ||
}); | ||
}); | ||
7868
165