Skip to content

Commit

Permalink
Merge pull request SUSE#721 from mssola/crono-missing-namespace
Browse files Browse the repository at this point in the history
jobs: fixed crono job when a repository could not be found
  • Loading branch information
mssola committed Feb 10, 2016
2 parents 8e7eb21 + efc33be commit 9164632
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/jobs/catalog_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def update_registry!(catalog)
Rails.logger.debug "skip upload not finished repo #{r["name"]}"
else
repository = Repository.create_or_update!(r)
dangling_repos.delete repository.id
dangling_repos.delete repository.id unless repository.nil?
end
end

Expand Down
18 changes: 18 additions & 0 deletions spec/jobs/catalog_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ def update_registry!(catalog)
tags = repo.tags
expect(tags.map(&:name)).to match_array(["latest"])
end

it "handles registries even if there some namespaces missing" do
registry = create(:registry, "hostname" => "registry.test.lan")

VCR.use_cassette("registry/get_registry_catalog_namespace_missing", record: :none) do
job = CatalogJobMock.new
job.perform
end

repos = Repository.all
expect(repos.count).to be 1
repo = repos[0]
expect(repo.name).to eq "busybox"
expect(repo.namespace.id).to eq registry.namespaces.first.id
tags = repo.tags
expect(tags.map(&:name)).to match_array(["latest"])
end

end

describe "Database already filled with repos" do
Expand Down
199 changes: 199 additions & 0 deletions spec/vcr_cassettes/registry/get_registry_catalog_namespace_missing.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9164632

Please sign in to comment.