class PactBroker::Domain::Verification
Constants
- FROM_JSON_WITH_SYMBOL_KEYS
- TO_JSON
Public Instance Methods
all_interactions_missing_test_results?()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 211 def all_interactions_missing_test_results? pact_content_with_test_results.interactions.count == pact_content_with_test_results.interactions_missing_test_results.count end
before_create()
click to toggle source
Calls superclass method
# File lib/pact_broker/domain/verification.rb, line 22 def before_create super self.execution_date ||= DateTime.now end
consumer(consumer_name)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 139 def consumer consumer_name where(name_like(:consumer_name, consumer_name)) end
consumer_name()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 187 def consumer_name consumer.name end
consumer_version_number(number)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 147 def consumer_version_number number where(name_like(:consumer_version_number, number)) end
delete()
click to toggle source
Calls superclass method
# File lib/pact_broker/domain/verification.rb, line 133 def delete require "pact_broker/webhooks/triggered_webhook" PactBroker::Webhooks::TriggeredWebhook.where(verification: self).delete super end
failed_and_pact_pending?()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 224 def failed_and_pact_pending? !success && pact_pending end
for_consumer_name(consumer_name)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 34 def for_consumer_name(consumer_name) where(consumer: PactBroker::Domain::Pacticipant.find_by_name(consumer_name)) end
for_consumer_name_and_consumer_version_number(consumer_name, consumer_version_number)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 174 def for_consumer_name_and_consumer_version_number(consumer_name, consumer_version_number) consumer_versions = PactBroker::Domain::Version.select(:id).where_pacticipant_name_and_version_number(consumer_name, consumer_version_number) join(:pact_publications, { Sequel[:pact_publications][:pact_version_id] => Sequel[:verifications][:pact_version_id], Sequel[:pact_publications][:consumer_version_id] => consumer_versions }) end
for_provider_name(provider_name)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 30 def for_provider_name(provider_name) where(provider: PactBroker::Domain::Pacticipant.find_by_name(provider_name)) end
from_provider_main_branch()
click to toggle source
TODO optimise this
# File lib/pact_broker/domain/verification.rb, line 39 def from_provider_main_branch providers_join = { Sequel[:verifications][:provider_id] => Sequel[:providers][:id] } branch_versions_join = { Sequel[:verifications][:provider_version_id] => Sequel[:branch_versions][:version_id], Sequel[:providers][:main_branch] => Sequel[:branch_versions][:branch_name] } join(:pacticipants, providers_join, { table_alias: :providers }) .join(:branch_versions, branch_versions_join) end
interactions_missing_test_results()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 207 def interactions_missing_test_results @interactions_missing_test_results ||= pact_content_with_test_results.interactions_missing_test_results end
join_pact_publications()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 170 def join_pact_publications join(:pact_publications, { Sequel[:pact_publications][:pact_version_id] => Sequel[:verifications][:pact_version_id] }) end
latest_by_pact_version()
click to toggle source
TODO change this to a group by
# File lib/pact_broker/domain/verification.rb, line 54 def latest_by_pact_version base_query = self base_join = { Sequel[:verifications][:pact_version_id] => Sequel[:v2][:pact_version_id] } if no_columns_selected? base_query = base_query.select_all_qualified end base_query.left_join(:latest_verification_id_for_pact_version_and_provider_version, base_join, { table_alias: :v2 }) do Sequel[:v2][:verification_id] > Sequel[:verifications][:id] end .where(Sequel[:v2][:verification_id] => nil) end
latest_pact_publication()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 203 def latest_pact_publication pact_version.latest_pact_publication end
method_missing(m, *args, **kwargs, &block)
click to toggle source
So consumer_version_tag_name can be accessed by method name
Calls superclass method
# File lib/pact_broker/domain/verification.rb, line 229 def method_missing(m, *args, **kwargs, &block) if values.key?(m) && args.size == 0 values[m] else super end end
pact_content_with_test_results()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 215 def pact_content_with_test_results @pact_content_with_test_results = PactBroker::Pacts::Content.from_json(pact_version.content).with_test_results(test_results) end
pact_pending?()
click to toggle source
Whether the pact content was pending at the time the verification was run
# File lib/pact_broker/domain/verification.rb, line 220 def pact_pending? pact_pending end
pact_version_sha(sha)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 151 def pact_version_sha sha where(pact_version_sha: sha) end
provider(provider_name)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 143 def provider provider_name where(name_like(:provider_name, provider_name)) end
provider_name()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 191 def provider_name provider.name end
provider_version_number()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 195 def provider_version_number provider_version.number end
provider_version_tag_names()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 199 def provider_version_tag_names provider_version.tags.collect(&:name) end
remove_verifications_for_overridden_consumer_versions()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 129 def remove_verifications_for_overridden_consumer_versions join(:latest_pact_publication_ids_for_consumer_versions, { pact_version_id: :pact_version_id } ) end
tag(tag_name)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 159 def tag tag_name filter = name_like(Sequel.qualify(:tags, :name), tag_name) join(:tags, { version_id: :consumer_version_id }).where(filter) end
untagged()
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 164 def untagged join(:pact_publications, {pact_version_id: :pact_version_id}) .left_outer_join(:tags, {version_id: :consumer_version_id}) .where(Sequel.qualify(:tags, :name) => nil) end
verification_number(number)
click to toggle source
# File lib/pact_broker/domain/verification.rb, line 155 def verification_number number where(Sequel.qualify("verifications", "number") => number) end