debian-mirror-gitlab/spec/factories/ci/runners.rb

94 lines
2.1 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2020-03-13 15:44:24 +05:30
factory :ci_runner, class: 'Ci::Runner' do
2017-08-17 22:00:37 +05:30
sequence(:description) { |n| "My runner#{n}" }
2015-09-25 12:07:36 +05:30
2019-12-21 20:55:43 +05:30
platform { "darwin" }
active { true }
access_level { :not_protected }
2015-09-25 12:07:36 +05:30
2019-12-21 20:55:43 +05:30
runner_type { :instance_type }
2018-11-08 19:23:39 +05:30
2021-11-18 22:05:49 +05:30
transient do
2021-12-11 22:18:48 +05:30
groups { [] }
2021-11-18 22:05:49 +05:30
projects { [] }
2022-04-04 11:22:00 +05:30
token_expires_at { nil }
2021-11-18 22:05:49 +05:30
end
after(:build) do |runner, evaluator|
evaluator.projects.each do |proj|
2022-08-27 11:52:29 +05:30
runner.runner_projects << build(:ci_runner_project, runner: runner, project: proj)
2021-11-18 22:05:49 +05:30
end
2021-12-11 22:18:48 +05:30
evaluator.groups.each do |group|
2022-08-27 11:52:29 +05:30
runner.runner_namespaces << build(:ci_runner_namespace, runner: runner, namespace: group)
2021-12-11 22:18:48 +05:30
end
2021-11-18 22:05:49 +05:30
end
2022-04-04 11:22:00 +05:30
after(:create) do |runner, evaluator|
runner.update!(token_expires_at: evaluator.token_expires_at) if evaluator.token_expires_at
end
2017-08-17 22:00:37 +05:30
trait :online do
2018-12-05 23:21:45 +05:30
contacted_at { Time.now }
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
trait :instance do
2019-12-21 20:55:43 +05:30
runner_type { :instance_type }
2018-11-08 19:23:39 +05:30
end
trait :group do
2019-12-21 20:55:43 +05:30
runner_type { :group_type }
2018-11-08 19:23:39 +05:30
after(:build) do |runner, evaluator|
2021-12-11 22:18:48 +05:30
if runner.runner_namespaces.empty?
runner.runner_namespaces << build(:ci_runner_namespace)
end
2018-11-08 19:23:39 +05:30
end
end
trait :project do
2019-12-21 20:55:43 +05:30
runner_type { :project_type }
2018-11-08 19:23:39 +05:30
after(:build) do |runner, evaluator|
2021-11-18 22:05:49 +05:30
if runner.runner_projects.empty?
runner.runner_projects << build(:ci_runner_project)
end
2018-11-08 19:23:39 +05:30
end
2015-09-25 12:07:36 +05:30
end
2016-09-29 09:46:39 +05:30
2018-11-08 19:23:39 +05:30
trait :without_projects do
# we use that to create invalid runner:
# the one without projects
after(:create) do |runner, evaluator|
runner.runner_projects.delete_all
end
2017-08-17 22:00:37 +05:30
end
2023-05-27 22:25:52 +05:30
trait :with_runner_machine do
after(:build) do |runner, evaluator|
runner.runner_machines << build(:ci_runner_machine, runner: runner)
end
end
2016-09-29 09:46:39 +05:30
trait :inactive do
2019-12-21 20:55:43 +05:30
active { false }
2016-09-29 09:46:39 +05:30
end
2018-03-17 18:26:18 +05:30
trait :ref_protected do
2019-12-21 20:55:43 +05:30
access_level { :ref_protected }
2018-03-17 18:26:18 +05:30
end
2018-12-13 13:39:08 +05:30
trait :tagged_only do
2019-12-21 20:55:43 +05:30
run_untagged { false }
2018-12-13 13:39:08 +05:30
2019-12-21 20:55:43 +05:30
tag_list { %w(tag1 tag2) }
2018-12-13 13:39:08 +05:30
end
trait :locked do
2019-12-21 20:55:43 +05:30
locked { true }
2018-12-13 13:39:08 +05:30
end
2015-09-25 12:07:36 +05:30
end
end