diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 15:10:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-06 15:10:58 +0300 |
commit | f2c27c6f97cf138acaed79b90be7a5be520746fc (patch) | |
tree | 369b09c536983f7b8682a8e66ebdac8fd6c54446 /spec/support | |
parent | b3c8b65ec2ab3af29d4d14eac27837e0c4793939 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/atlassian/jira_connect/schemata.rb | 233 | ||||
-rw-r--r-- | spec/support/capybara.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/test_env.rb | 2 |
3 files changed, 170 insertions, 67 deletions
diff --git a/spec/support/atlassian/jira_connect/schemata.rb b/spec/support/atlassian/jira_connect/schemata.rb index 91f8fe0bb41..75c18a89276 100644 --- a/spec/support/atlassian/jira_connect/schemata.rb +++ b/spec/support/atlassian/jira_connect/schemata.rb @@ -2,82 +2,185 @@ module Atlassian module Schemata - def self.build_info - { - 'type' => 'object', - 'required' => %w(schemaVersion pipelineId buildNumber updateSequenceNumber displayName url state issueKeys testInfo references), - 'properties' => { - 'schemaVersion' => { 'type' => 'string', 'pattern' => '1.0' }, - 'pipelineId' => { 'type' => 'string' }, - 'buildNumber' => { 'type' => 'integer' }, - 'updateSequenceNumber' => { 'type' => 'integer' }, - 'displayName' => { 'type' => 'string' }, - 'url' => { 'type' => 'string' }, - 'state' => { - 'type' => 'string', - 'pattern' => '(pending|in_progress|successful|failed|cancelled)' - }, - 'issueKeys' => { - 'type' => 'array', - 'items' => { 'type' => 'string' }, - 'minItems' => 1 - }, - 'testInfo' => { - 'type' => 'object', - 'required' => %w(totalNumber numberPassed numberFailed numberSkipped), - 'properties' => { - 'totalNumber' => { 'type' => 'integer' }, - 'numberFailed' => { 'type' => 'integer' }, - 'numberPassed' => { 'type' => 'integer' }, - 'numberSkipped' => { 'type' => 'integer' } - } - }, - 'references' => { - 'type' => 'array', - 'items' => { + class << self + def build_info + { + 'type' => 'object', + 'additionalProperties' => false, + 'required' => %w( + schemaVersion pipelineId buildNumber updateSequenceNumber + displayName url state issueKeys testInfo references + lastUpdated + ), + 'properties' => { + 'schemaVersion' => schema_version_type, + 'pipelineId' => { 'type' => 'string' }, + 'buildNumber' => { 'type' => 'integer' }, + 'updateSequenceNumber' => { 'type' => 'integer' }, + 'displayName' => { 'type' => 'string' }, + 'lastUpdated' => { 'type' => 'string' }, + 'url' => { 'type' => 'string' }, + 'state' => state_type, + 'issueKeys' => issue_keys_type, + 'testInfo' => { 'type' => 'object', - 'required' => %w(commit ref), + 'required' => %w(totalNumber numberPassed numberFailed numberSkipped), 'properties' => { - 'commit' => { - 'type' => 'object', - 'required' => %w(id repositoryUri), - 'properties' => { - 'id' => { 'type' => 'string' }, - 'repositoryUri' => { 'type' => 'string' } - } - }, - 'ref' => { - 'type' => 'object', - 'required' => %w(name uri), - 'properties' => { - 'name' => { 'type' => 'string' }, - 'uri' => { 'type' => 'string' } + 'totalNumber' => { 'type' => 'integer' }, + 'numberFailed' => { 'type' => 'integer' }, + 'numberPassed' => { 'type' => 'integer' }, + 'numberSkipped' => { 'type' => 'integer' } + } + }, + 'references' => { + 'type' => 'array', + 'items' => { + 'type' => 'object', + 'required' => %w(commit ref), + 'properties' => { + 'commit' => { + 'type' => 'object', + 'required' => %w(id repositoryUri), + 'properties' => { + 'id' => { 'type' => 'string' }, + 'repositoryUri' => { 'type' => 'string' } + } + }, + 'ref' => { + 'type' => 'object', + 'required' => %w(name uri), + 'properties' => { + 'name' => { 'type' => 'string' }, + 'uri' => { 'type' => 'string' } + } } } } } } } - } - end + end - def self.build_info_payload - { - 'type' => 'object', - 'required' => %w(providerMetadata builds), - 'properties' => { - 'providerMetadata' => provider_metadata, - 'builds' => { 'type' => 'array', 'items' => build_info } + def deployment_info + { + 'type' => 'object', + 'additionalProperties' => false, + 'required' => %w( + deploymentSequenceNumber updateSequenceNumber + associations displayName url description lastUpdated + state pipeline environment + ), + 'properties' => { + 'deploymentSequenceNumber' => { 'type' => 'integer' }, + 'updateSequenceNumber' => { 'type' => 'integer' }, + 'associations' => { + 'type' => 'array', + 'items' => association_type, + 'minItems' => 1 + }, + 'displayName' => { 'type' => 'string' }, + 'description' => { 'type' => 'string' }, + 'label' => { 'type' => 'string' }, + 'url' => { 'type' => 'string' }, + 'lastUpdated' => { 'type' => 'string' }, + 'state' => state_type, + 'pipeline' => pipeline_type, + 'environment' => environment_type, + 'schemaVersion' => schema_version_type + } } - } - end + end + + def environment_type + { + 'type' => 'object', + 'additionalProperties' => false, + 'required' => %w(id displayName type), + 'properties' => { + 'id' => { 'type' => 'string', 'maxLength' => 255 }, + 'displayName' => { 'type' => 'string', 'maxLength' => 255 }, + 'type' => { + 'type' => 'string', + 'pattern' => '(unmapped|development|testing|staging|production)' + } + } + } + end + + def pipeline_type + { + 'type' => 'object', + 'additionalProperties' => false, + 'required' => %w(id displayName url), + 'properties' => { + 'id' => { 'type' => 'string', 'maxLength' => 255 }, + 'displayName' => { 'type' => 'string', 'maxLength' => 255 }, + 'url' => { 'type' => 'string', 'maxLength' => 2000 } + } + } + end + + def schema_version_type + { 'type' => 'string', 'pattern' => '1.0' } + end - def self.provider_metadata - { - 'type' => 'object', - 'required' => %w(product), - 'properties' => { 'product' => { 'type' => 'string' } } - } + def state_type + { + 'type' => 'string', + 'pattern' => '(pending|in_progress|successful|failed|cancelled)' + } + end + + def association_type + { + 'type' => 'object', + 'additionalProperties' => false, + 'required' => %w(associationType values), + 'properties' => { + 'associationType' => { + 'type' => 'string', + 'pattern' => '(issueKeys|issueIdOrKeys)' + }, + 'values' => issue_keys_type + } + } + end + + def issue_keys_type + { + 'type' => 'array', + 'items' => { 'type' => 'string' }, + 'minItems' => 1, + 'maxItems' => 100 + } + end + + def deploy_info_payload + payload('deployments', deployment_info) + end + + def build_info_payload + payload('builds', build_info) + end + + def payload(key, schema) + { + 'type' => 'object', + 'required' => ['providerMetadata', key], + 'properties' => { + 'providerMetadata' => provider_metadata, + key => { 'type' => 'array', 'items' => schema } + } + } + end + + def provider_metadata + { + 'type' => 'object', + 'required' => %w(product), + 'properties' => { 'product' => { 'type' => 'string' } } + } + end end end end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index ab55cf97ab4..db198ac9808 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -33,7 +33,7 @@ Capybara.register_server :puma_via_workhorse do |app, port, host, **options| socket_path = file.path file.close! # We just want the filename - TestEnv.with_workhorse(TestEnv.workhorse_dir, host, port, socket_path) do + TestEnv.with_workhorse(host, port, socket_path) do Capybara.servers[:puma].call(app, nil, socket_path, **options) end end diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 01571277a1d..c438da02a31 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -284,7 +284,7 @@ module TestEnv @workhorse_path ||= File.join('tmp', 'tests', 'gitlab-workhorse') end - def with_workhorse(workhorse_dir, host, port, upstream, &blk) + def with_workhorse(host, port, upstream, &blk) host = "[#{host}]" if host.include?(':') listen_addr = [host, port].join(':') |