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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
2.2 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
return if Rails.env.production?
require 'pact/tasks/verification_task'
2022-08-27 11:52:29 +05:30
provider = File.expand_path('../../../spec/contracts/provider', __dir__)
2022-08-13 15:12:31 +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 :pipelines do
2022-08-27 11:52:29 +05:30
Pact::VerificationTask.new(:create_a_new_pipeline) do |pact|
2023-03-04 22:38:38 +05:30
pact_helper_location = "pact_helpers/project/pipelines/new/post_create_a_new_pipeline_helper.rb"
2022-08-27 11:52:29 +05:30
pact.uri(
2023-03-04 22:38:38 +05:30
Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
pact_helper: "#{provider}/#{pact_helper_location}"
2022-08-27 11:52:29 +05:30
)
end
2022-08-13 15:12:31 +05:30
Pact::VerificationTask.new(:get_list_project_pipelines) do |pact|
2023-03-04 22:38:38 +05:30
pact_helper_location = "pact_helpers/project/pipelines/index/get_list_project_pipelines_helper.rb"
2022-08-13 15:12:31 +05:30
pact.uri(
2023-03-04 22:38:38 +05:30
Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
pact_helper: "#{provider}/#{pact_helper_location}"
2022-08-13 15:12:31 +05:30
)
end
Pact::VerificationTask.new(:get_pipeline_header_data) do |pact|
2023-03-04 22:38:38 +05:30
pact_helper_location = "pact_helpers/project/pipelines/show/get_pipeline_header_data_helper.rb"
2022-08-13 15:12:31 +05:30
pact.uri(
2023-03-04 22:38:38 +05:30
Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
pact_helper: "#{provider}/#{pact_helper_location}"
2022-08-27 11:52:29 +05:30
)
end
Pact::VerificationTask.new(:delete_pipeline) do |pact|
2023-03-04 22:38:38 +05:30
pact_helper_location = "pact_helpers/project/pipelines/show/delete_pipeline_helper.rb"
2022-08-27 11:52:29 +05:30
pact.uri(
2023-03-04 22:38:38 +05:30
Provider::ContractSourceHelper.contract_location(:rake, pact_helper_location),
pact_helper: "#{provider}/#{pact_helper_location}"
2022-08-13 15:12:31 +05:30
)
end
desc 'Run all pipeline contract tests'
2022-08-27 11:52:29 +05:30
task 'test:pipelines', :contract_pipelines do |_t, arg|
errors = %w[
create_a_new_pipeline
get_list_project_pipelines
get_pipeline_header_data
delete_pipeline
].each_with_object([]) do |task, err|
2022-08-13 15:12:31 +05:30
Rake::Task["contracts:pipelines:pact:verify:#{task}"].execute
rescue StandardError, SystemExit
err << "contracts:pipelines:pact:verify:#{task}"
end
raise StandardError, "Errors in tasks #{errors.join(', ')}" unless errors.empty?
end
end
end