mirror of
https://github.com/discourse/discourse.git
synced 2025-09-08 12:06:51 +08:00
DEV: Raise exceptions when jobs fail in test mode
Previously jobs would fail silently in test mode. Now they will raise the exception and cause the relevant test to fail. This identified a few broken tests, which I will fix in a followup commit
This commit is contained in:
parent
5e68c5f851
commit
20cda5d689
2 changed files with 10 additions and 2 deletions
|
@ -274,7 +274,10 @@ describe Discourse do
|
|||
it "should not fail when called" do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_job_exception(exception, nil, nil)
|
||||
expect do
|
||||
Discourse.handle_job_exception(exception, nil, nil)
|
||||
end.to raise_error(StandardError) # Raises in test mode, catch it
|
||||
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys).to eq([:current_db, :current_hostname])
|
||||
end
|
||||
|
@ -282,7 +285,10 @@ describe Discourse do
|
|||
it "correctly passes extra context" do
|
||||
exception = StandardError.new
|
||||
|
||||
Discourse.handle_job_exception(exception, { message: "Doing a test", post_id: 31 }, nil)
|
||||
expect do
|
||||
Discourse.handle_job_exception(exception, { message: "Doing a test", post_id: 31 }, nil)
|
||||
end.to raise_error(StandardError) # Raises in test mode, catch it
|
||||
|
||||
expect(logger.exception).to eq(exception)
|
||||
expect(logger.context.keys.sort).to eq([:current_db, :current_hostname, :message, :post_id].sort)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue