summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalmyr Lima e Silva Filho <walmyr@gitlab.com>2019-08-23 14:06:23 +0000
committerWalmyr Lima e Silva Filho <walmyr@gitlab.com>2019-08-23 14:06:23 +0000
commit1352f433dc92a8d91f624e6a563a9f82af62fa6a (patch)
treecdcab2f33864dd44c07cfc9f0af41961d6d4e219
parent681fca60f664c47562ce9151202983a5c7f9ba35 (diff)
parent99327de207965fe85e6c7759ebb2ef014b3574e8 (diff)
downloadgitlab-ce-1352f433dc92a8d91f624e6a563a9f82af62fa6a.tar.gz
Merge branch 'qa-ml-fail-early-if-template-not-found' into 'master'
Fail E2E tests early if template not found via API See merge request gitlab-org/gitlab-ce!31955
-rw-r--r--qa/qa/runtime/api/request.rb4
-rw-r--r--qa/qa/runtime/fixtures.rb13
2 files changed, 15 insertions, 2 deletions
diff --git a/qa/qa/runtime/api/request.rb b/qa/qa/runtime/api/request.rb
index 310c1dfeeb4..724b499d32f 100644
--- a/qa/qa/runtime/api/request.rb
+++ b/qa/qa/runtime/api/request.rb
@@ -12,6 +12,10 @@ module QA
@session_address = Runtime::Address.new(api_client.address, request_path)
end
+ def mask_url
+ @session_address.address.sub(/private_token=.*/, "private_token=[****]")
+ end
+
def url
@session_address.address
end
diff --git a/qa/qa/runtime/fixtures.rb b/qa/qa/runtime/fixtures.rb
index 72004d5b00a..02cecffd4df 100644
--- a/qa/qa/runtime/fixtures.rb
+++ b/qa/qa/runtime/fixtures.rb
@@ -3,10 +3,19 @@
module QA
module Runtime
module Fixtures
+ include Support::Api
+
+ TemplateNotFoundError = Class.new(RuntimeError)
+
def fetch_template_from_api(api_path, key)
request = Runtime::API::Request.new(api_client, "/templates/#{api_path}/#{key}")
- get request.url
- json_body[:content]
+ response = get(request.url)
+
+ unless response.code == HTTP_STATUS_OK
+ raise TemplateNotFoundError, "Template at #{request.mask_url} could not be found (#{response.code}): `#{response}`."
+ end
+
+ parse_body(response)[:content]
end
private