-
-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(publisher-electron-release-server): throw an exception for 4xx/5x…
…x HTTP status codes (#1538)
- Loading branch information
1 parent
28dbb19
commit f223fc8
Showing
3 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/publisher/electron-release-server/test/PublisherERS_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { expect } from 'chai'; | ||
import { ForgeConfig } from '@electron-forge/shared-types'; | ||
import fetchMock from 'fetch-mock'; | ||
import proxyquire from 'proxyquire'; | ||
|
||
describe('PublisherERS', () => { | ||
let fetch: typeof fetchMock; | ||
beforeEach(() => { | ||
fetch = fetchMock.sandbox(); | ||
}); | ||
it('fail if the server returns 4xx', async () => { | ||
fetch.mock('begin:http://example.com', { body: {}, status: 400 }); | ||
const PublisherERS = proxyquire.noCallThru().load('../src/PublisherERS', { | ||
'node-fetch': fetch, | ||
}).default; | ||
|
||
|
||
const publisher = new PublisherERS({ | ||
baseUrl: 'http://example.com', | ||
username: 'test', | ||
password: 'test', | ||
}); | ||
return expect(publisher.publish({ makeResults: [], dir: '', forgeConfig: {} as ForgeConfig })).to.eventually.be.rejectedWith('ERS publish failed with status code: 400 (http://example.com/api/auth/login)'); | ||
}); | ||
|
||
afterEach(() => { | ||
fetch.restore(); | ||
}); | ||
}); |