2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
FactoryBot.define do
|
|
|
|
factory :terraform_state, class: 'Terraform::State' do
|
2021-01-29 00:20:46 +05:30
|
|
|
project { association(:project) }
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
sequence(:name) { |n| "state-#{n}" }
|
|
|
|
|
|
|
|
trait :with_file do
|
2020-11-24 15:15:51 +05:30
|
|
|
versioning_enabled { false }
|
2020-04-22 19:07:51 +05:30
|
|
|
file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate', 'application/json') }
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
trait :locked do
|
|
|
|
sequence(:lock_xid) { |n| "lock-#{n}" }
|
|
|
|
locked_at { Time.current }
|
2021-01-29 00:20:46 +05:30
|
|
|
locked_by_user { association(:user) }
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
trait :with_version do
|
|
|
|
after(:create) do |state|
|
2021-01-29 00:20:46 +05:30
|
|
|
create(:terraform_state_version, terraform_state: state)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Remove with https://gitlab.com/gitlab-org/gitlab/-/issues/235108
|
|
|
|
factory :legacy_terraform_state, parent: :terraform_state, traits: [:with_file]
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
|
|
|
end
|