BigW Consortium Gitlab

builds.rb 2.36 KB
Newer Older
1 2
include ActionDispatch::TestProcess

3
FactoryGirl.define do
4
  factory :ci_build, class: Ci::Build do
5
    name 'test'
6 7
    stage 'test'
    stage_idx 0
8 9
    ref 'master'
    tag false
10
    status 'pending'
11
    created_at 'Di 29. Okt 09:50:00 CET 2013'
12 13
    started_at 'Di 29. Okt 09:51:28 CET 2013'
    finished_at 'Di 29. Okt 09:53:28 CET 2013'
Kamil Trzcinski committed
14
    commands 'ls -a'
15 16 17 18 19 20
    options do
      {
        image: "ruby:2.1",
        services: ["postgres"]
      }
    end
21 22 23 24 25
    yaml_variables do
      [
        { key: :DB_NAME, value: 'postgres', public: true }
      ]
    end
26

27
    pipeline factory: :ci_pipeline
28

29 30 31 32 33 34 35 36
    trait :success do
      status 'success'
    end

    trait :failed do
      status 'failed'
    end

37 38 39 40
    trait :canceled do
      status 'canceled'
    end

41 42 43 44 45 46 47 48
    trait :running do
      status 'running'
    end

    trait :pending do
      status 'pending'
    end

49 50 51 52
    trait :created do
      status 'created'
    end

53 54 55 56 57
    trait :manual do
      status 'skipped'
      self.when 'manual'
    end

58 59 60 61
    trait :allowed_to_fail do
      allow_failure true
    end

62
    after(:build) do |build, evaluator|
63
      build.project = build.pipeline.project
64 65
    end

Dmitriy Zaporozhets committed
66
    factory :ci_not_started_build do
67 68 69
      started_at nil
      finished_at nil
    end
70 71 72 73

    factory :ci_build_tag do
      tag true
    end
74

75 76 77 78
    factory :ci_build_with_coverage do
      coverage 99.9
    end

Kamil Trzcinski committed
79
    trait :trace do
80
      after(:create) do |build, evaluator|
81 82
        build.trace = 'BUILD TRACE'
      end
83
    end
84 85 86 87

    trait :artifacts do
      after(:create) do |build, _|
        build.artifacts_file =
88 89
          fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
                             'application/zip')
90 91

        build.artifacts_metadata =
92
          fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
93
                             'application/x-gzip')
94

95 96 97
        build.save!
      end
    end
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113

    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
114 115
  end
end