Welcome to mirror list, hosted at ThFree Co, Russian Federation.

project.rb « events « resource « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 693fdd6168f49c789514938b62344c3a6f87f2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

module QA
  module Resource
    module Events
      module Project
        include Events::Base

        def push_events(commit_message)
          QA::Runtime::Logger.info(%[#{self.class.name} - wait for and fetch push events"])
          fetch_events do
            events(action: 'pushed').select { |event| event.dig(:push_data, :commit_title) == commit_message }
          end
        end

        def wait_for_merge(title)
          QA::Runtime::Logger.info(%[#{self.class.name} - wait_for_merge with title "#{title}"])
          wait_for_event do
            events(action: 'accepted', target_type: 'merge_request').any? { |event| event[:target_title] == title }
          end
        end

        def wait_for_push(commit_message)
          QA::Runtime::Logger.info(%[#{self.class.name} - wait_for_push with commit message "#{commit_message}"])
          wait_for_event do
            events(action: 'pushed').any? { |event| event.dig(:push_data, :commit_title) == commit_message }
          end
        rescue EventNotFoundError
          QA::Runtime::Logger.info("Push events: #{events(action: 'pushed')}")

          raise
        end

        def wait_for_push_new_branch(branch_name = self.default_branch)
          QA::Runtime::Logger.info(%[#{self.class.name} - wait_for_push_new_branch with branch_name "#{branch_name}"])
          wait_for_event do
            events(action: 'pushed').any? { |event| event.dig(:push_data, :ref) == branch_name }
          end
        end
      end
    end
  end
end