Commit 2ab01aa7 authored by Jan Provaznik's avatar Jan Provaznik

Use hexadecimal checksum

The problem is that 'my_checksum' is converted internally
into a hexadecimal sha - both in rails4 and rails5 `my_checksum` is
converted ans saved as `62fc1ec4ce60`.

The difference is that in rails 4 `repository_verification_checksum` is
stored as '62fc1ec4ce60' on record save, but loaded instance of
`RepositoryState` has `repository_verification_checksum` stil lset to
`my_checksum`. Reloading the record loads the saved value of course.

In rails 5 `repository_verification_checksum` attribute of loaded
instance is updated on record save (not sure what has changed
internally but it seems that the test was passing only because
the record was not reloaded because different checksum is actually
stored in database. This patch updates the test to use real hexadecimal
checksum which is also closer to real usage.
parent 071d60bb
...@@ -33,8 +33,8 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -33,8 +33,8 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
end end
it 'does not verify the checksum if the current checksum matches' do it 'does not verify the checksum if the current checksum matches' do
repository_state.assign_attributes("#{type}_verification_checksum" => 'my_checksum') repository_state.assign_attributes("#{type}_verification_checksum" => '62fc1ec4ce60')
registry.assign_attributes("#{type}_verification_checksum_sha" => 'my_checksum') registry.assign_attributes("#{type}_verification_checksum_sha" => '62fc1ec4ce60')
expect(repository).not_to receive(:checksum) expect(repository).not_to receive(:checksum)
...@@ -42,12 +42,12 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -42,12 +42,12 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
end end
it 'sets checksum when the checksum matches' do it 'sets checksum when the checksum matches' do
allow(repository).to receive(:checksum).and_return('my_checksum') allow(repository).to receive(:checksum).and_return('62fc1ec4ce60')
service.execute service.execute
expect(registry).to have_attributes( expect(registry).to have_attributes(
"#{type}_verification_checksum_sha" => 'my_checksum', "#{type}_verification_checksum_sha" => '62fc1ec4ce60',
"#{type}_checksum_mismatch" => false, "#{type}_checksum_mismatch" => false,
"last_#{type}_verification_failure" => nil, "last_#{type}_verification_failure" => nil,
"#{type}_verification_retry_count" => nil, "#{type}_verification_retry_count" => nil,
...@@ -155,7 +155,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do ...@@ -155,7 +155,7 @@ describe Geo::RepositoryVerificationSecondaryService, :geo do
describe '#execute' do describe '#execute' do
let(:project) { create(:project, :repository, :wiki_repo) } let(:project) { create(:project, :repository, :wiki_repo) }
let!(:repository_state) { create(:repository_state, project: project, repository_verification_checksum: 'my_checksum', wiki_verification_checksum: 'my_checksum') } let!(:repository_state) { create(:repository_state, project: project, repository_verification_checksum: '62fc1ec4ce60', wiki_verification_checksum: '62fc1ec4ce60') }
let(:registry) { create(:geo_project_registry, :synced, project: project) } let(:registry) { create(:geo_project_registry, :synced, project: project) }
context 'for a repository' do context 'for a repository' do
......
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