Merge pull request #2492 from alecmerdler/fix-build-service
Null Case for Frontend Retrieving Build Message
This commit is contained in:
commit
52eab1766a
2 changed files with 7 additions and 2 deletions
|
@ -37,6 +37,7 @@ describe("BuildServiceImpl", () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
buildMessages = [
|
buildMessages = [
|
||||||
|
{phase: null, message: ""},
|
||||||
{phase: 'cannot_load', message: 'Cannot load build status'},
|
{phase: 'cannot_load', message: 'Cannot load build status'},
|
||||||
{phase: 'starting', message: 'Starting Dockerfile build'},
|
{phase: 'starting', message: 'Starting Dockerfile build'},
|
||||||
{phase: 'initializing', message: 'Starting Dockerfile build'},
|
{phase: 'initializing', message: 'Starting Dockerfile build'},
|
||||||
|
@ -69,7 +70,7 @@ describe("BuildServiceImpl", () => {
|
||||||
buildServiceImpl.getBuildMessage(phase);
|
buildServiceImpl.getBuildMessage(phase);
|
||||||
fail("Should throw error");
|
fail("Should throw error");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toEqual("Invalid build phase");
|
expect(error.message).toEqual(`Invalid build phase: ${phase.toString()}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,10 @@ export class BuildServiceImpl implements BuildService {
|
||||||
public getBuildMessage(phase: string): string {
|
public getBuildMessage(phase: string): string {
|
||||||
var message: string;
|
var message: string;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
|
case null:
|
||||||
|
message = '';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'cannot_load':
|
case 'cannot_load':
|
||||||
message = 'Cannot load build status';
|
message = 'Cannot load build status';
|
||||||
break;
|
break;
|
||||||
|
@ -76,7 +80,7 @@ export class BuildServiceImpl implements BuildService {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid build phase");
|
throw new Error(`Invalid build phase: ${phase.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
|
|
Reference in a new issue