Skip to content

Commit

Permalink
Handle case where we do not receive any logs back (#163)
Browse files Browse the repository at this point in the history
* Handle case where we do not receive any logs back
* matching test
  • Loading branch information
purplecabbage authored May 13, 2020
1 parent c181408 commit 41713e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commands/runtime/activation/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ActivationLogs extends RuntimeBaseCommand {
if (flags.last) {
const limit = Math.max(1, Math.min(flags.count, 5))
activations = await ow.activations.list({ limit: limit, skip: 0 })
if (!activations || activations.length < 1) {
this.log('No activations to log.')
return
}
}
if (!activations[0].activationId) {
// just a thought, but we could just return --last activation log when no id is present
Expand Down
10 changes: 10 additions & 0 deletions test/commands/runtime/activation/logs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ describe('instance methods', () => {
})
})

test('retrieve last logs - no-results', () => {
const cmd = ow.mockResolved('activations.list', [])
command.argv = ['-l']
return command.run()
.then(() => {
expect(cmd).toHaveBeenCalledWith(expect.objectContaining({ limit: 1 }))
expect(stdout.output).toMatch('')
})
})

test('retrieve last log --last', () => {
const listCmd = ow.mockResolved('activations.list', [{ activationId: '12345' }])
const logCmd = ow.mockResolved(owAction, { logs: ['line1', 'line2', 'line3'] })
Expand Down

0 comments on commit 41713e2

Please sign in to comment.