blob: 5630a9c02c5fa3302e72264e5eac33e1dd00ef62 (
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
44
45
46
47
48
49
50
51
52
53
|
# frozen_string_literal: true
module QA
module Runtime
module API
module RepositoryStorageMoves
extend self
extend Support::Api
RepositoryStorageMovesError = Class.new(RuntimeError)
def has_status?(resource, status, destination_storage = Env.additional_repository_storage)
find_any(resource) do |move|
next unless resource_equals?(resource, move)
QA::Runtime::Logger.debug("Move data: #{move}")
move[:state] == status &&
move[:destination_storage_name] == destination_storage
end
end
def find_any(resource)
Logger.debug('Getting repository storage moves')
Support::Waiter.wait_until do
with_paginated_response_body(Request.new(api_client, "/#{resource_name(resource)}_repository_storage_moves", per_page: '100').url) do |page|
break true if page.any? { |item| yield item }
end
end
end
def resource_equals?(resource, move)
if resource.class.name.include?('Snippet')
move[:snippet][:id] == resource.id
else
move[:project][:path_with_namespace] == resource.path_with_namespace
end
end
def resource_name(resource)
resource.class.name.split('::').last.downcase
end
private
def api_client
@api_client ||= Client.as_admin
end
end
end
end
end
|