Skip to content

Commit

Permalink
[ci] Add backend calls to project and package factories
Browse files Browse the repository at this point in the history
Certain parts of OBS send http requests to the backend. For that to work we
need project, package and probably other factories to correctly setup the
backend for the created objects.
  • Loading branch information
bgeuken committed Sep 21, 2016
1 parent ceaad5d commit 72ddc55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/api/spec/factories/packages.rb
Expand Up @@ -2,13 +2,22 @@
factory :package do
project
sequence(:name) { |n| "package_#{n}" }

after(:create) do |package|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
if CONFIG['global_write_through']
Suse::Backend.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/_meta", package.to_axml)
end
end

factory :package_with_file do
after(:create) do |package|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
Suse::Backend.put("/source/#{CGI.escape(package.project.name)}/_meta", package.project.to_axml)
Suse::Backend.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/_meta", package.to_axml)
Suse::Backend.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/somefile.txt", Faker::Lorem.paragraph)
if CONFIG['global_write_through']
Suse::Backend.put("/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/somefile.txt", Faker::Lorem.paragraph)
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions src/api/spec/factories/project.rb
Expand Up @@ -3,6 +3,14 @@
sequence(:name) { |n| "project_#{n}" }
title { Faker::Book.title }

after(:create) do |project|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
if CONFIG['global_write_through']
Suse::Backend.put("/source/#{CGI.escape(project.name)}/_meta", project.to_axml)
end
end

# remote projects validate additional the description and remoteurl
factory :remote_project do
description { Faker::Lorem.sentence }
Expand Down

0 comments on commit 72ddc55

Please sign in to comment.