Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/reporting/monthly_proofing_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def proofing_report
end

csv
rescue Aws::CloudWatchLogs::Errors::MalformedQueryException => error
[
['Error', 'Message'],
[error.class.name, error.message],
]
end

def as_csv
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/reporting/monthly_proofing_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,28 @@
end
end

describe '#proofing_report' do
context 'when the data is outside the log retention range' do
before do
allow(report.cloudwatch_client).to receive(:fetch).and_raise(
Aws::CloudWatchLogs::Errors::MalformedQueryException.new(
nil,
'exceeds the log groups log retention settings',
),
)
end

it 'handles the error and returns a table with information on the error' do
expect(report.proofing_report).to match(
[
['Error', 'Message'],
['Aws::CloudWatchLogs::Errors::MalformedQueryException', kind_of(String)],
],
)
end
end
end

describe '#data' do
it 'keeps unique users per event as a hash' do
expect(report.data).to eq(
Expand Down