Commit 051bd55a authored by Mike Kozono's avatar Mike Kozono

Ensure perform is idempotent

The important bit is idempotent anyway. This would
update timestamps and such, multiple times.
parent 2305d9be
......@@ -6,6 +6,7 @@ RSpec.describe Geo::VerificationWorker, :geo do
include EE::GeoHelpers
let(:package_file) { create(:conan_package_file, :conan_recipe_file) }
let(:job_args) { ['package_file', package_file.id] }
describe '#perform' do
it 'calls calculate_checksum!' do
......@@ -14,17 +15,21 @@ RSpec.describe Geo::VerificationWorker, :geo do
expect(replicator).to receive(:calculate_checksum!)
described_class.new.perform('package_file', package_file.id)
described_class.new.perform(*job_args)
end
context 'when on a primary node' do
before do
stub_primary_node
package_file.update!(verification_checksum: nil)
end
it 'calculates the checksum' do
expect { described_class.new.perform('package_file', package_file.id) }
.to change { package_file.reload.verification_checksum }.from(nil)
it_behaves_like 'an idempotent worker' do
it 'calculates the checksum' do
described_class.new.perform(*job_args)
expect(package_file.reload.verification_checksum).to eq('ee66543d50acf8dfe39cbc0bbd40d4a801e479ecf5f90ebef9f2321eeb4bf09b')
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment