Module: PactBroker::Verifications::Service
Constant Summary
Repositories::REPOSITORY_FACTORIES
Constants included
from Services
Services::SERVICE_FACTORIES
Instance Method Summary
collapse
-
#calculate_required_verifications_for_pact(pact) ⇒ Object
-
#create(next_verification_number, params, verified_pacts, event_context) ⇒ Object
TODO use a decorator instead of passing in params, srsly, Beth verified_pacts is an array of SelectedPact objects.
-
#delete(verification) ⇒ Object
-
#delete_all_verifications_between(consumer_name, options) ⇒ Object
-
#find(params) ⇒ Object
-
#find_by_id(id) ⇒ Object
-
#find_latest_for_pact(pact) ⇒ Object
-
#find_latest_verification_for(consumer, provider, tag = nil) ⇒ Object
-
#find_latest_verification_for_tags(consumer_name, provider_name, consumer_version_tag_name, provider_version_tag_name) ⇒ Object
-
#find_latest_verifications_for_consumer_version(params) ⇒ Object
-
#next_number ⇒ Object
-
#search_for_latest(consumer_name, provider_name) ⇒ Object
-
#verification_summary_for_consumer_version(params) ⇒ Object
branch_repository, branch_version_repository, get_repository, integration_repository, label_repository, matrix_repository, pact_repository, pacticipant_repository, register_default_repositories, register_repository, tag_repository, verification_repository, version_repository, webhook_repository
Methods included from Services
badge_service, branch_service, certificate_service, contract_service, deployed_version_service, environment_service, get_service, group_service, index_service, integration_service, label_service, matrix_service, metrics_service, pact_service, pacticipant_service, register_default_services, register_service, released_version_service, tag_service, verification_service, version_service, webhook_service, webhook_trigger_service
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
Instance Method Details
#calculate_required_verifications_for_pact(pact) ⇒ Object
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/pact_broker/verifications/service.rb', line 102
def calculate_required_verifications_for_pact(pact)
pact_version = PactBroker::Pacts::PactVersion.for_pact_domain(pact)
required_verifications = required_verifications_for_main_branch(pact_version, pact.provider.main_branch) +
required_verifications_for_deployed_versions(pact_version) +
required_verifications_for_released_versions(pact_version)
required_verifications
.group_by(&:provider_version)
.values
.flat_map { | required_verifications_for_provider_version | required_verifications_for_provider_version.reduce(&:+) }
end
|
#create(next_verification_number, params, verified_pacts, event_context) ⇒ Object
TODO use a decorator instead of passing in params, srsly, Beth verified_pacts is an array of SelectedPact objects
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/pact_broker/verifications/service.rb', line 38
def create next_verification_number, params, verified_pacts, event_context
first_verified_pact = verified_pacts.first
logger.info("Creating verification #{next_verification_number} for pact_version_sha=#{first_verified_pact.pact_version_sha}", params.without("testResults"))
verification = PactBroker::Domain::Verification.new
provider_version_number = params.fetch("providerApplicationVersion")
PactBroker::Api::Decorators::VerificationDecorator.new(verification).from_hash(params)
verification.wip = params.fetch("wip")
verification.pact_pending = params.fetch("pending")
verification.number = next_verification_number
verification.verified_by_implementation = params.dig("verifiedBy", "implementation")
verification.verified_by_version = params.dig("verifiedBy", "version")
verification.consumer_version_selector_hashes = event_context[:consumer_version_selectors]
pact_version = pact_repository.find_pact_version(first_verified_pact.consumer, first_verified_pact.provider, first_verified_pact.pact_version_sha)
verification = verification_repository.create(verification, provider_version_number, pact_version)
broadcast_events(verification, first_verified_pact.pact, event_context)
verification
end
|
#delete(verification) ⇒ Object
59
60
61
62
|
# File 'lib/pact_broker/verifications/service.rb', line 59
def delete(verification)
webhook_service.delete_all_webhook_related_objects_by_verification_ids(verification.id)
verification_repository.delete(verification.id)
end
|
#delete_all_verifications_between(consumer_name, options) ⇒ Object
98
99
100
|
# File 'lib/pact_broker/verifications/service.rb', line 98
def delete_all_verifications_between(consumer_name, options)
verification_repository.delete_all_verifications_between(consumer_name, options)
end
|
#find(params) ⇒ Object
64
65
66
|
# File 'lib/pact_broker/verifications/service.rb', line 64
def find params
verification_repository.find(params.fetch(:consumer_name), params.fetch(:provider_name), params.fetch(:pact_version_sha), params.fetch(:verification_number))
end
|
#find_latest_for_pact(pact) ⇒ Object
68
69
70
|
# File 'lib/pact_broker/verifications/service.rb', line 68
def find_latest_for_pact(pact)
verification_repository.find_latest_for_pact(pact)
end
|
#find_latest_verification_for(consumer, provider, tag = nil) ⇒ Object
80
81
82
|
# File 'lib/pact_broker/verifications/service.rb', line 80
def find_latest_verification_for consumer, provider, tag = nil
verification_repository.find_latest_verification_for consumer.name, provider.name, tag
end
|
84
85
86
|
# File 'lib/pact_broker/verifications/service.rb', line 84
def find_latest_verification_for_tags consumer_name, provider_name, consumer_version_tag_name, provider_version_tag_name
verification_repository.find_latest_verification_for_tags(consumer_name, provider_name, consumer_version_tag_name, provider_version_tag_name)
end
|
#find_latest_verifications_for_consumer_version(params) ⇒ Object
76
77
78
|
# File 'lib/pact_broker/verifications/service.rb', line 76
def find_latest_verifications_for_consumer_version params
verification_repository.find_latest_verifications_for_consumer_version params[:consumer_name], params[:consumer_version_number]
end
|
#next_number ⇒ Object
28
29
30
|
# File 'lib/pact_broker/verifications/service.rb', line 28
def next_number
verification_repository.next_number
end
|
#search_for_latest(consumer_name, provider_name) ⇒ Object
88
89
90
|
# File 'lib/pact_broker/verifications/service.rb', line 88
def search_for_latest consumer_name, provider_name
verification_repository.search_for_latest(consumer_name, provider_name)
end
|
#verification_summary_for_consumer_version(params) ⇒ Object
92
93
94
95
96
|
# File 'lib/pact_broker/verifications/service.rb', line 92
def verification_summary_for_consumer_version params
verifications = find_latest_verifications_for_consumer_version(params)
pacts = pact_service.find_by_consumer_version(params)
SummaryForConsumerVersion.new(verifications, pacts)
end
|