diff options
Diffstat (limited to 'spec/requests/api/ci/runners_spec.rb')
-rw-r--r-- | spec/requests/api/ci/runners_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/requests/api/ci/runners_spec.rb b/spec/requests/api/ci/runners_spec.rb index 2b2d2e0def8..7b69e9d1cb0 100644 --- a/spec/requests/api/ci/runners_spec.rb +++ b/spec/requests/api/ci/runners_spec.rb @@ -249,6 +249,39 @@ RSpec.describe API::Ci::Runners, :aggregate_failures, feature_category: :runner_ a_hash_including('description' => 'Runner tagged with tag1 and tag2') ] end + + context 'with ci_runner_machines' do + let_it_be(:version_ci_runner) { create(:ci_runner, :project, description: 'Runner with machine') } + let_it_be(:version_ci_runner_machine) { create(:ci_runner_machine, runner: version_ci_runner, version: '15.0.3') } + let_it_be(:version_16_ci_runner) { create(:ci_runner, :project, description: 'Runner with machine version 16') } + let_it_be(:version_16_ci_runner_machine) { create(:ci_runner_machine, runner: version_16_ci_runner, version: '16.0.1') } + + it 'filters runners by version_prefix when prefix is "15.0"' do + get api('/runners/all?version_prefix=15.0', admin, admin_mode: true) + + expect(json_response).to match_array [ + a_hash_including('description' => 'Runner with machine', 'active' => true, 'paused' => false) + ] + end + + it 'filters runners by version_prefix when prefix is "16"' do + get api('/runners/all?version_prefix=16', admin, admin_mode: true) + expect(json_response).to match_array [ + a_hash_including('description' => 'Runner with machine version 16', 'active' => true, 'paused' => false) + ] + end + + it 'filters runners by version_prefix when prefix is "25"' do + get api('/runners/all?version_prefix=25', admin, admin_mode: true) + expect(json_response).to match_array [] + end + + it 'does not filter runners by version_prefix when prefix is invalid ("V15")' do + get api('/runners/all?version_prefix=v15', admin, admin_mode: true) + + expect(response).to have_gitlab_http_status(:bad_request) + end + end end context 'without admin privileges' do |