مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-03-04 06:44:06 +00:00
test: add tests for message unqueueing
This adds a comprehensive set of tests for the message unqueueing service. Additionally, it improves how message databases are used for testing environments.
هذا الالتزام موجود في:
36
spec/app/services/unqueue_message_service_spec.rb
Normal file
36
spec/app/services/unqueue_message_service_spec.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe UnqueueMessageService do
|
||||
let(:server) { create(:server) }
|
||||
let(:logger) { TestLogger.new }
|
||||
let(:queued_message) { create(:queued_message, server: server) }
|
||||
subject(:service) { described_class.new(queued_message: queued_message, logger: logger) }
|
||||
|
||||
describe "#call" do
|
||||
context "when the backend message does not exist" do
|
||||
it "deletes the queued message" do
|
||||
service.call
|
||||
expect(logger).to have_logged(/unqueue because backend message has been removed/)
|
||||
expect { queued_message.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context "when the message is not ready for processing" do
|
||||
let(:message) { MessageFactory.outgoing(server) }
|
||||
let(:queued_message) { create(:queued_message, :retry_in_future, message: message) }
|
||||
|
||||
it "does not do anything" do
|
||||
service.call
|
||||
expect(logger).to have_logged(/skipping because message isn't ready for processing/)
|
||||
end
|
||||
end
|
||||
|
||||
context "when there are other messages to batch with this one" do
|
||||
context "when the backend message of a sub-message has been removed" do
|
||||
it "removes the queued message for that message"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
المرجع في مشكلة جديدة
حظر مستخدم