Skip to content

Commit

Permalink
fixed an issue with 577 error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmaclean committed Jan 21, 2025
1 parent 608729e commit 52ec5a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/RokuDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,38 @@ describe('index', () => {
assert.fail('Should not have succeeded');
});

it('Should throw an excpetion', async () => {
it('Should throw an exception and call doPost once', async () => {
options.failOnCompileError = true;
let spy = mockDoPostRequest('', 577);

try {
await rokuDeploy.publish(options);
} catch (e) {
expect(spy.callCount).to.eql(1);
assert.ok('Exception was thrown as expected');
expect(e).to.be.instanceof(errors.UpdateCheckRequiredError);
return;
}
assert.fail('Should not have succeeded');
});

it('Should throw an exception and should call doPost twice', async () => {
options.failOnCompileError = true;
mockDoPostRequest('', 577);
let spy = sinon.stub(rokuDeploy as any, 'doPostRequest').callsFake((params: any) => {
let results: any;
if (params?.formData['mysubmit'] === 'Replace') {
results = { response: { statusCode: 500 }, body: `'not an update error'` };
} else {
results = { response: { statusCode: 577 }, body: `` };
}
rokuDeploy['checkRequest'](results);
return Promise.resolve(results);
});

try {
await rokuDeploy.publish(options);
} catch (e) {
expect(spy.callCount).to.eql(2);
assert.ok('Exception was thrown as expected');
expect(e).to.be.instanceof(errors.UpdateCheckRequiredError);
return;
Expand Down
2 changes: 2 additions & 0 deletions src/RokuDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ export class RokuDeploy {
//fail if this is a compile error
if (this.isCompileError(replaceError.message) && options.failOnCompileError) {
throw new errors.CompileError('Compile error', replaceError, replaceError.results);
} else if (replaceError?.results?.response?.statusCode === 577 || (typeof replaceError?.results?.body === 'string' && this.isUpdateCheckRequiredResponse(replaceError.results.body))) {
throw replaceError;
} else {
requestOptions.formData.mysubmit = 'Install';
response = await this.doPostRequest(requestOptions);
Expand Down

0 comments on commit 52ec5a1

Please sign in to comment.