Skip to content

Commit

Permalink
added tests to verify loud failure on missing uploads in BE
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelclement committed Nov 29, 2024
1 parent 5265ff1 commit fe2da6a
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@

expect(response).to have_http_status(:ok)
end

it 'returns a 500 error when supporting documents are submitted, but are missing from the database' do
allow_any_instance_of(Aws::S3::Client).to receive(:put_object).and_return(true)

# Actual supporting_docs should exist as records in the DB. This test
# ensures that if they aren't present we won't have a silent failure
data_with_docs = data.merge({ supporting_docs: [{ confirmation_code: 'NOT_IN_DATABASE' }] })
post '/ivc_champva/v1/forms', params: data_with_docs

expect(response).to have_http_status(:internal_server_error)
end
end
end

Expand Down Expand Up @@ -159,6 +170,19 @@
'attachment_ids' => %w[doc0 doc1] # Ensure this matches the sorted order
})
end

it 'throws an error when no matching supporting doc is present in the database' do
controller = IvcChampva::V1::UploadsController.new
parsed_form_data = {
'form_number' => '10-10D',
'supporting_docs' => [
{ 'attachment_id' => 'doc0', 'confirmation_code' => 'NOT_IN_DATABASE' }
]
}
expect do
controller.send(:supporting_document_ids, parsed_form_data)
end.to raise_error(NoMethodError)
end
end

describe '#get_file_paths_and_metadata' do
Expand Down

0 comments on commit fe2da6a

Please sign in to comment.