Class: PactBroker::Pacts::PactsForVerificationRepository

Inherits:
Object
  • Object
show all
Includes:
Logging, Repositories, Repositories::Scopes, Services
Defined in:
lib/pact_broker/pacts/pacts_for_verification_repository.rb

Overview

rubocop: disable Metrics/ClassLength

Constant Summary collapse

PUBLICATION_ASSOCIATIONS_FOR_EAGER_LOAD =
[
  :provider,
  :consumer,
  :consumer_version,
  :pact_version
]

Constants included from Services

Services::SERVICE_FACTORIES

Constants included from Repositories

Repositories::REPOSITORY_FACTORIES

Instance Method Summary collapse

Methods included from Repositories::Scopes

#scope_for, #unscoped, #with_no_scope

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 Repositories

#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 Logging

included, #log_error, #log_with_tag, #measure_info

Instance Method Details

#find(provider_name, consumer_version_selectors) ⇒ VerifiablePact

Returns an array of VerifiablePact objects.

Returns:



29
30
31
32
33
# File 'lib/pact_broker/pacts/pacts_for_verification_repository.rb', line 29

def find(provider_name, consumer_version_selectors)
  selected_pacts = find_pacts_by_selector(provider_name, consumer_version_selectors)
  selected_pacts = selected_pacts + find_pacts_for_fallback_tags(selected_pacts, provider_name, consumer_version_selectors)
  merge_selected_pacts(selected_pacts)
end

#find_wip(provider_name, provider_version_branch, provider_tags_names, explicitly_specified_verifiable_pacts, options = {}) ⇒ Object

To find the work in progress pacts for this verification execution: For each provider tag that will be applied to this verification result (usually there will just be one, but we have to allow for multiple tags), find the head pacts (the pacts that are the latest for their tag) that have been successfully verified against the provider tag. Then, find all the head pacts, and remove the ones that have been successfully verified by ALL of the provider tags supplied, and the ones that were published before the include_wip_pacts_since date. Then, for all of the head pacts that are remaining (these are the WIP ones) work out which provider tags they are pending for. Don’t include pact publications that were created before the provider tag was first used (that is, before the provider’s git branch was created).



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/pact_broker/pacts/pacts_for_verification_repository.rb', line 46

def find_wip(provider_name, provider_version_branch, provider_tags_names, explicitly_specified_verifiable_pacts, options = {})
  # TODO not sure about this
  if provider_tags_names.empty? && provider_version_branch == nil
    log_debug_for_wip do
      logger.debug("No provider tags or branch provided. Cannot calculate WIP pacts. Returning an empty list.")
    end
    return []
  end

  if provider_version_branch
    return find_wip_pact_versions_for_provider_by_provider_branch(provider_name, provider_version_branch, explicitly_specified_verifiable_pacts, options)
  end

  provider = pacticipant_repository.find_by_name(provider_name)
  wip_start_date = options.fetch(:include_wip_pacts_since)

  wip_by_consumer_tags = find_wip_pact_versions_for_provider_by_provider_tags(
    provider,
    provider_tags_names,
    wip_start_date,
    explicitly_specified_verifiable_pacts,
    :for_all_tag_heads
  )

  wip_by_consumer_branches = find_wip_pact_versions_for_provider_by_provider_tags(
    provider,
    provider_tags_names,
    wip_start_date,
    explicitly_specified_verifiable_pacts,
    :for_all_branch_heads
  )

  deduplicate_verifiable_pacts(wip_by_consumer_tags + wip_by_consumer_branches).sort
end