debian-mirror-gitlab/lib/tasks/contracts/merge_requests.rake

52 lines
1.9 KiB
Ruby
Raw Normal View History

2022-05-07 20:08:51 +05:30
# frozen_string_literal: true
2022-07-23 23:45:48 +05:30
return if Rails.env.production?
2022-05-07 20:08:51 +05:30
require 'pact/tasks/verification_task'
2022-08-27 11:52:29 +05:30
provider = File.expand_path('../../../spec/contracts/provider', __dir__)
2022-05-07 20:08:51 +05:30
namespace :contracts do
2023-03-04 22:38:38 +05:30
require_relative "../../../spec/contracts/provider/helpers/contract_source_helper"
2022-08-13 15:12:31 +05:30
namespace :merge_requests do
2023-03-04 22:38:38 +05:30
Pact::VerificationTask.new(:get_diffs_batch) do |pact|
pact_helper_location = "pact_helpers/project/merge_requests/show/get_diffs_batch_helper.rb"
2022-05-07 20:08:51 +05:30
pact.uri(
2023-03-17 16:20:25 +05:30
Provider::ContractSourceHelper.contract_location(requester: :rake, file_path: pact_helper_location),
2023-03-04 22:38:38 +05:30
pact_helper: "#{provider}/#{pact_helper_location}"
2022-05-07 20:08:51 +05:30
)
end
2023-03-04 22:38:38 +05:30
Pact::VerificationTask.new(:get_diffs_metadata) do |pact|
pact_helper_location = "pact_helpers/project/merge_requests/show/get_diffs_metadata_helper.rb"
2023-03-17 16:20:25 +05:30
2022-05-07 20:08:51 +05:30
pact.uri(
2023-03-17 16:20:25 +05:30
Provider::ContractSourceHelper.contract_location(requester: :rake, file_path: pact_helper_location),
2023-03-04 22:38:38 +05:30
pact_helper: "#{provider}/#{pact_helper_location}"
2022-05-07 20:08:51 +05:30
)
end
2023-03-04 22:38:38 +05:30
Pact::VerificationTask.new(:get_discussions) do |pact|
pact_helper_location = "pact_helpers/project/merge_requests/show/get_discussions_helper.rb"
2022-05-07 20:08:51 +05:30
pact.uri(
2023-03-17 16:20:25 +05:30
Provider::ContractSourceHelper.contract_location(requester: :rake, file_path: pact_helper_location),
2023-03-04 22:38:38 +05:30
pact_helper: "#{provider}/#{pact_helper_location}"
2022-05-07 20:08:51 +05:30
)
end
desc 'Run all merge request contract tests'
2022-08-27 11:52:29 +05:30
task 'test:merge_requests', :contract_merge_requests do |_t, arg|
2023-03-17 16:20:25 +05:30
errors = %w[get_diffs_batch get_diffs_metadata get_discussions].each_with_object([]) do |task, err|
2022-08-27 11:52:29 +05:30
Rake::Task["contracts:merge_requests:pact:verify:#{task}"].execute
2022-05-07 20:08:51 +05:30
rescue StandardError, SystemExit
2022-08-13 15:12:31 +05:30
err << "contracts:merge_requests:pact:verify:#{task}"
2022-05-07 20:08:51 +05:30
end
raise StandardError, "Errors in tasks #{errors.join(', ')}" unless errors.empty?
end
end
end