Skip to content

Commit 8d7f1ee

Browse files
authored
fix: deploy - output the error from the audit log api if --verbose is set (#853)
1 parent 42c4daf commit 8d7f1ee

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

src/commands/app/deploy.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ class Deploy extends BuildCommand {
111111
// only send logs in case of web-assets deployment
112112
await sendAuditLogs(cliDetails.accessToken, assetDeployedLogEvent, cliDetails.env)
113113
} catch (error) {
114-
this.warn('Error: Audit Log Service Error: Failed to send audit log event for deployment.')
114+
if (flags.verbose) {
115+
this.warn('Error: Audit Log Service Error: Failed to send audit log event for deployment.')
116+
this.warn(error.message)
117+
}
115118
}
116119
}
117120
}

test/commands/app/deploy.test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,4 +1487,52 @@ describe('run', () => {
14871487
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
14881488
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1)
14891489
})
1490+
1491+
test('Should deploy successfully even if Audit log service is unavailable (--verbose)', async () => {
1492+
const mockToken = 'mocktoken'
1493+
const mockEnv = 'stage'
1494+
const mockOrg = 'mockorg'
1495+
const mockProject = 'mockproject'
1496+
const mockWorkspaceId = 'mockworkspaceid'
1497+
const mockWorkspaceName = 'mockworkspacename'
1498+
helpers.getCliInfo.mockResolvedValueOnce({
1499+
accessToken: mockToken,
1500+
env: mockEnv
1501+
})
1502+
command.getFullConfig = jest.fn().mockReturnValue({
1503+
aio: {
1504+
project: {
1505+
id: mockProject,
1506+
org: {
1507+
id: mockOrg
1508+
},
1509+
workspace: {
1510+
id: mockWorkspaceId,
1511+
name: mockWorkspaceName
1512+
}
1513+
}
1514+
}
1515+
})
1516+
1517+
auditLogger.sendAuditLogs.mockRejectedValue({
1518+
message: 'Internal Server Error',
1519+
status: 500
1520+
})
1521+
1522+
command.getAppExtConfigs.mockResolvedValueOnce(createAppConfig(command.appConfig))
1523+
1524+
command.argv = ['--verbose']
1525+
await command.run()
1526+
expect(command.log).toHaveBeenCalledWith(
1527+
expect.stringContaining('skipping publish phase...')
1528+
)
1529+
1530+
expect(command.log).toHaveBeenCalledWith(
1531+
expect.stringContaining('Successful deployment 🏄')
1532+
)
1533+
expect(auditLogger.sendAuditLogs).toHaveBeenCalledTimes(1)
1534+
expect(command.error).toHaveBeenCalledTimes(0)
1535+
expect(mockRuntimeLib.deployActions).toHaveBeenCalledTimes(1)
1536+
expect(mockWebLib.deployWeb).toHaveBeenCalledTimes(1)
1537+
})
14901538
})

0 commit comments

Comments
 (0)