From 99327de207965fe85e6c7759ebb2ef014b3574e8 Mon Sep 17 00:00:00 2001 From: Mark Lapierre Date: Fri, 23 Aug 2019 14:06:22 +0000 Subject: Fail E2E tests early if template not found via API --- qa/qa/runtime/api/request.rb | 4 ++++ qa/qa/runtime/fixtures.rb | 13 +++++++++++-- 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 -- cgit v1.2.1