Recalculates the checksum for projects up to date

parent 1c817595
...@@ -18,8 +18,8 @@ module Geo ...@@ -18,8 +18,8 @@ module Geo
return if project.nil? || project.pending_delete? return if project.nil? || project.pending_delete?
try_obtain_lease do try_obtain_lease do
calculate_repository_checksum if repository_state.repository_verification_checksum.nil? calculate_repository_checksum
calculate_wiki_checksum if repository_state.wiki_verification_checksum.nil? calculate_wiki_checksum
end end
end end
......
...@@ -78,45 +78,27 @@ describe Geo::RepositoryVerification::Primary::SingleWorker, :postgresql, :clean ...@@ -78,45 +78,27 @@ describe Geo::RepositoryVerification::Primary::SingleWorker, :postgresql, :clean
) )
end end
it 'calculates the checksum for outdated repositories' do it 'calculates the checksum for outdated repositories/wikis' do
stub_project_repository(project, repository) stub_project_repository(project, repository)
repository_state =
create(:repository_state,
project: project,
repository_verification_checksum: nil,
wiki_verification_checksum: 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef')
subject.perform(project.id)
expect(repository_state.reload).to have_attributes(
repository_verification_checksum: 'f123',
last_repository_verification_failure: nil,
wiki_verification_checksum: 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef',
last_wiki_verification_failure: nil
)
end
it 'calculates the checksum for outdated wikis' do
stub_wiki_repository(project.wiki, wiki) stub_wiki_repository(project.wiki, wiki)
repository_state = repository_state =
create(:repository_state, create(:repository_state,
project: project, project: project,
repository_verification_checksum: 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee', repository_verification_checksum: nil,
wiki_verification_checksum: nil) wiki_verification_checksum: nil)
subject.perform(project.id) subject.perform(project.id)
expect(repository_state.reload).to have_attributes( expect(repository_state.reload).to have_attributes(
repository_verification_checksum: 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee', repository_verification_checksum: 'f123',
last_repository_verification_failure: nil, last_repository_verification_failure: nil,
wiki_verification_checksum: 'e321', wiki_verification_checksum: 'e321',
last_wiki_verification_failure: nil last_wiki_verification_failure: nil
) )
end end
it 'does not recalculate the checksum for projects up to date' do it 'recalculates the checksum for projects up to date' do
stub_project_repository(project, repository) stub_project_repository(project, repository)
stub_wiki_repository(project.wiki, wiki) stub_wiki_repository(project.wiki, wiki)
...@@ -125,8 +107,8 @@ describe Geo::RepositoryVerification::Primary::SingleWorker, :postgresql, :clean ...@@ -125,8 +107,8 @@ describe Geo::RepositoryVerification::Primary::SingleWorker, :postgresql, :clean
repository_verification_checksum: 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee', repository_verification_checksum: 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee',
wiki_verification_checksum: 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef') wiki_verification_checksum: 'e079a831cab27bcda7d81cd9b48296d0c3dd92ef')
expect(repository).not_to receive(:checksum) expect(repository).to receive(:checksum)
expect(wiki).not_to receive(:checksum) expect(wiki).to receive(:checksum)
subject.perform(project.id) subject.perform(project.id)
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