gitlab-org--gitlab-foss/spec/factories/ci/builds.rb

133 lines
2.6 KiB
Ruby
Raw Normal View History

include ActionDispatch::TestProcess
2015-08-25 21:42:46 -04:00
FactoryGirl.define do
factory :ci_build, class: Ci::Build do
2015-10-06 06:01:16 -04:00
name 'test'
stage 'test'
stage_idx 0
ref 'master'
tag false
status 'pending'
created_at 'Di 29. Okt 09:50:00 CET 2013'
2015-08-25 21:42:46 -04:00
started_at 'Di 29. Okt 09:51:28 CET 2013'
finished_at 'Di 29. Okt 09:53:28 CET 2013'
2015-10-05 08:31:51 -04:00
commands 'ls -a'
2015-08-25 21:42:46 -04:00
options do
{
image: "ruby:2.1",
services: ["postgres"]
}
end
yaml_variables do
[
{ key: 'DB_NAME', value: 'postgres', public: true }
]
end
2015-08-25 21:42:46 -04:00
pipeline factory: :ci_pipeline
trait :success do
status 'success'
end
trait :failed do
status 'failed'
end
trait :canceled do
status 'canceled'
end
trait :skipped do
status 'skipped'
end
trait :running do
status 'running'
end
trait :pending do
status 'pending'
end
trait :created do
status 'created'
end
trait :manual do
status 'skipped'
self.when 'manual'
end
trait :teardown_environment do
environment 'staging'
options environment: { name: 'staging',
action: 'stop' }
end
trait :allowed_to_fail do
allow_failure true
end
trait :playable do
skipped
manual
end
2015-12-04 06:55:23 -05:00
after(:build) do |build, evaluator|
2016-06-03 07:09:49 -04:00
build.project = build.pipeline.project
2015-12-04 06:55:23 -05:00
end
2015-09-10 09:52:52 -04:00
factory :ci_not_started_build do
2015-08-25 21:42:46 -04:00
started_at nil
finished_at nil
end
factory :ci_build_tag do
tag true
end
factory :ci_build_with_coverage do
coverage 99.9
end
2016-02-19 12:06:53 -05:00
trait :trace do
after(:create) do |build, evaluator|
2016-01-11 10:30:01 -05:00
build.trace = 'BUILD TRACE'
end
end
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'),
2016-02-10 08:09:11 -05:00
'application/x-gzip')
build.save!
end
end
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
2015-08-25 21:42:46 -04:00
end
end