blob: 86875df70a2cc635672d70a9eab83c3a2c2184ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Runners::UpdateRunnerService, '#execute', feature_category: :runner_fleet do
subject(:execute) { described_class.new(runner).execute(params) }
let(:runner) { create(:ci_runner) }
before do
allow(runner).to receive(:tick_runner_queue)
end
context 'with description params' do
let(:params) { { description: 'new runner' } }
it 'updates the runner and ticking the queue' do
expect(execute).to be_success
runner.reload
expect(runner).to have_received(:tick_runner_queue)
expect(runner.description).to eq('new runner')
end
end
context 'with paused param' do
let(:params) { { paused: true } }
it 'updates the runner and ticking the queue' do
expect(runner.active).to be_truthy
expect(execute).to be_success
runner.reload
expect(runner).to have_received(:tick_runner_queue)
expect(runner.active).to be_falsey
end
end
context 'with cost factor params' do
let(:params) { { public_projects_minutes_cost_factor: 1.1, private_projects_minutes_cost_factor: 2.2 } }
it 'updates the runner cost factors' do
expect(execute).to be_success
runner.reload
expect(runner.public_projects_minutes_cost_factor).to eq(1.1)
expect(runner.private_projects_minutes_cost_factor).to eq(2.2)
end
end
context 'when params are not valid' do
let(:params) { { run_untagged: false } }
it 'does not update and returns error because it is not valid' do
expect(execute).to be_error
runner.reload
expect(runner).not_to have_received(:tick_runner_queue)
expect(runner.run_untagged).to be_truthy
end
end
end
|