Class: PactBroker::Pacts::PactsForVerificationRepository

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

Constant Summary

Constants included from Services

Services::FACTORIES

Instance Method Summary collapse

Methods included from Repositories::Scopes

#scope_for, #unscoped, #with_no_scope

Methods included from Repositories::Helpers

#mysql?, #name_like, #no_columns_selected?, #order_append_ignore_case, #order_ignore_case, #pacticipant_id_for_name, #postgres?, #select_all_qualified, #select_append_all_qualified, #select_for_subquery

Methods included from Services

#badge_service, #branch_service, #certificate_service, #contract_service, #deployed_version_service, #environment_service, #get, #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_version_repository, #label_repository, #matrix_repository, #pact_repository, #pacticipant_repository, #tag_repository, #verification_repository, #version_repository, #webhook_repository

Methods included from Logging

included, #log_error, #log_with_tag

Instance Method Details

#find(provider_name, consumer_version_selectors) ⇒ Object



22
23
24
25
26
# File 'lib/pact_broker/pacts/pacts_for_verification_repository.rb', line 22

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, specified_pact_version_shas, 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).



39
40
41
42
43
44
45
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
# File 'lib/pact_broker/pacts/pacts_for_verification_repository.rb', line 39

def find_wip provider_name, provider_version_branch, provider_tags_names, specified_pact_version_shas, 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, specified_pact_version_shas, 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,
    specified_pact_version_shas,
    :latest_by_consumer_tag
  )

  wip_by_consumer_branches = find_wip_pact_versions_for_provider_by_provider_tags(
    provider,
    provider_tags_names,
    wip_start_date,
    specified_pact_version_shas,
    :latest_by_consumer_branch
  )

  deduplicate_verifiable_pacts(wip_by_consumer_tags + wip_by_consumer_branches).sort
end