diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/lib/api/ci/helpers/runner_helpers_spec.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/lib/api/ci/helpers/runner_helpers_spec.rb')
-rw-r--r-- | spec/lib/api/ci/helpers/runner_helpers_spec.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/lib/api/ci/helpers/runner_helpers_spec.rb b/spec/lib/api/ci/helpers/runner_helpers_spec.rb new file mode 100644 index 00000000000..c6638bea59e --- /dev/null +++ b/spec/lib/api/ci/helpers/runner_helpers_spec.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe API::Ci::Helpers::Runner do + let(:ip_address) { '1.2.3.4' } + let(:runner_class) do + Class.new do + include API::Helpers + include API::Ci::Helpers::Runner + + attr_accessor :params + + def initialize(params) + @params = params + end + + def ip_address + '1.2.3.4' + end + end + end + + let(:runner_helper) { runner_class.new(runner_params) } + + describe '#get_runner_details_from_request' do + context 'when no runner info is present' do + let(:runner_params) { {} } + + it 'returns the runner IP' do + expect(runner_helper.get_runner_details_from_request).to eq({ ip_address: ip_address }) + end + end + + context 'when runner info is present' do + let(:name) { 'runner' } + let(:version) { '1.2.3' } + let(:revision) { '10.0' } + let(:platform) { 'test' } + let(:architecture) { 'arm' } + let(:config) { { 'gpus' => 'all' } } + let(:runner_params) do + { + 'info' => + { + 'name' => name, + 'version' => version, + 'revision' => revision, + 'platform' => platform, + 'architecture' => architecture, + 'config' => config, + 'ignored' => 1 + } + } + end + + subject(:details) { runner_helper.get_runner_details_from_request } + + it 'extracts the runner details', :aggregate_failures do + expect(details.keys).to match_array(%w(name version revision platform architecture config ip_address)) + expect(details['name']).to eq(name) + expect(details['version']).to eq(version) + expect(details['revision']).to eq(revision) + expect(details['platform']).to eq(platform) + expect(details['architecture']).to eq(architecture) + expect(details['config']).to eq(config) + expect(details['ip_address']).to eq(ip_address) + end + end + end +end |