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

215 lines
4.2 KiB
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
include ActionDispatch::TestProcess
2015-09-25 12:07:36 +05:30
FactoryGirl.define do
factory :ci_build, class: Ci::Build do
2015-10-24 18:46:33 +05:30
name 'test'
2016-08-24 12:49:21 +05:30
stage 'test'
stage_idx 0
2015-10-24 18:46:33 +05:30
ref 'master'
tag false
2016-09-13 17:45:13 +05:30
status 'pending'
created_at 'Di 29. Okt 09:50:00 CET 2013'
2015-09-25 12:07:36 +05:30
started_at 'Di 29. Okt 09:51:28 CET 2013'
finished_at 'Di 29. Okt 09:53:28 CET 2013'
commands 'ls -a'
2017-08-17 22:00:37 +05:30
2015-09-25 12:07:36 +05:30
options do
{
2017-08-17 22:00:37 +05:30
image: 'ruby:2.1',
services: ['postgres']
2015-09-25 12:07:36 +05:30
}
end
2017-08-17 22:00:37 +05:30
2016-08-24 12:49:21 +05:30
yaml_variables do
[
2017-08-17 22:00:37 +05:30
{ key: 'DB_NAME', value: 'postgres', public: true }
2016-08-24 12:49:21 +05:30
]
end
2015-09-25 12:07:36 +05:30
pipeline factory: :ci_pipeline
2015-09-25 12:07:36 +05:30
2016-04-02 18:10:28 +05:30
trait :success do
status 'success'
end
trait :failed do
status 'failed'
end
trait :canceled do
status 'canceled'
end
2017-08-17 22:00:37 +05:30
trait :skipped do
status 'skipped'
end
2016-04-02 18:10:28 +05:30
trait :running do
status 'running'
end
trait :pending do
status 'pending'
end
2016-09-13 17:45:13 +05:30
trait :created do
status 'created'
end
2016-08-24 12:49:21 +05:30
trait :manual do
2017-08-17 22:00:37 +05:30
status 'manual'
2016-08-24 12:49:21 +05:30
self.when 'manual'
end
2017-08-17 22:00:37 +05:30
trait :teardown_environment do
environment 'staging'
options environment: { name: 'staging',
action: 'stop' }
end
2016-04-02 18:10:28 +05:30
trait :allowed_to_fail do
allow_failure true
end
2017-08-17 22:00:37 +05:30
trait :ignored do
allowed_to_fail
end
trait :playable do
manual
end
trait :retryable do
success
end
trait :cancelable do
pending
end
trait :erasable do
success
artifacts
end
trait :tags do
tag_list [:docker, :ruby]
end
trait :on_tag do
tag true
end
trait :triggered do
trigger_request factory: :ci_trigger_request_with_variables
end
2015-12-23 02:04:40 +05:30
after(:build) do |build, evaluator|
build.project = build.pipeline.project
2015-12-23 02:04:40 +05:30
end
2015-09-25 12:07:36 +05:30
factory :ci_not_started_build do
started_at nil
finished_at nil
end
2015-10-24 18:46:33 +05:30
factory :ci_build_tag do
tag true
end
2017-08-17 22:00:37 +05:30
trait :coverage do
2016-06-02 11:05:42 +05:30
coverage 99.9
2017-08-17 22:00:37 +05:30
coverage_regex '/(d+)/'
2016-06-02 11:05:42 +05:30
end
2016-04-02 18:10:28 +05:30
trait :trace do
after(:create) do |build, evaluator|
2017-08-17 22:00:37 +05:30
build.trace.set('BUILD TRACE')
end
end
2016-04-02 18:10:28 +05:30
2017-08-17 22:00:37 +05:30
trait :erased do
erased_at Time.now
erased_by factory: :user
end
trait :queued do
queued_at Time.now
runner factory: :ci_runner
end
2016-04-02 18:10:28 +05:30
trait :artifacts do
after(:create) do |build, _|
build.artifacts_file =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
'application/zip')
build.artifacts_metadata =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
'application/x-gzip')
2016-06-02 11:05:42 +05:30
2016-04-02 18:10:28 +05:30
build.save!
end
end
2016-09-13 17:45:13 +05:30
trait :artifacts_expired do
after(:create) do |build, _|
build.artifacts_file =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
'application/zip')
build.artifacts_metadata =
fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
'application/x-gzip')
build.artifacts_expire_at = 1.minute.ago
build.save!
end
end
2017-08-17 22:00:37 +05:30
trait :with_commit do
after(:build) do |build|
allow(build).to receive(:commit).and_return build(:commit, :without_author)
end
end
trait :with_commit_and_author do
after(:build) do |build|
allow(build).to receive(:commit).and_return build(:commit)
end
end
trait :extended_options do
options do
{
image: 'ruby:2.1',
services: ['postgres'],
after_script: %w(ls date),
artifacts: {
name: 'artifacts_file',
untracked: false,
paths: ['out/'],
when: 'always',
expire_in: '7d'
},
cache: {
key: 'cache_key',
untracked: false,
paths: ['vendor/*']
}
}
end
end
trait :no_options do
options { {} }
end
trait :non_playable do
status 'created'
self.when 'manual'
end
2015-09-25 12:07:36 +05:30
end
end