Commit dcbe6ed0 authored by Mike Kozono's avatar Mike Kozono

Rename #calculate_checksum! to #verify

This helps to differentiate `VerifiableReplicator#verify` from
`ReplicableModel#calculate_checksum!`.
parent 88cf7733
......@@ -50,7 +50,7 @@ module Geo
schedule_checksum_calculation if needs_checksum?
end
def calculate_checksum!
def verify
checksum = model_record.calculate_checksum!
update_verification_state!(checksum: checksum)
rescue => e
......
......@@ -14,7 +14,7 @@ module Geo
def perform(replicable_name, replicable_id)
replicator = ::Gitlab::Geo::Replicator.for_replicable_params(replicable_name: replicable_name, replicable_id: replicable_id)
replicator.calculate_checksum!
replicator.verify
rescue ActiveRecord::RecordNotFound
log_error("Couldn't find the record, skipping", replicable_name: replicable_name, replicable_id: replicable_id)
end
......
......@@ -48,7 +48,7 @@ RSpec.shared_examples 'a verifiable replicator' do
end
end
describe '#calculate_checksum!' do
describe '#verify' do
before do
model_record.save!
end
......@@ -56,7 +56,7 @@ RSpec.shared_examples 'a verifiable replicator' do
it 'calculates the checksum' do
expect(model_record).to receive(:calculate_checksum!).and_return('abc123')
replicator.calculate_checksum!
replicator.verify
expect(model_record.reload.verification_checksum).to eq('abc123')
expect(model_record.verified_at).not_to be_nil
......@@ -67,7 +67,7 @@ RSpec.shared_examples 'a verifiable replicator' do
raise StandardError.new('Failure to calculate checksum')
end
replicator.calculate_checksum!
replicator.verify
expect(model_record.reload.verification_failure).to eq 'Failure to calculate checksum'
expect(model_record.verification_retry_count).to be 1
......
......@@ -9,11 +9,11 @@ RSpec.describe Geo::VerificationWorker, :geo do
let(:job_args) { ['package_file', package_file.id] }
describe '#perform' do
it 'calls calculate_checksum!' do
it 'calls verify' do
replicator = double(:replicator)
allow(::Gitlab::Geo::Replicator).to receive(:for_replicable_params).with(replicable_name: 'package_file', replicable_id: package_file.id).and_return(replicator)
expect(replicator).to receive(:calculate_checksum!)
expect(replicator).to receive(:verify)
described_class.new.perform(*job_args)
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