diff options
Diffstat (limited to 'spec/factories/ml')
-rw-r--r-- | spec/factories/ml/candidate_metrics.rb | 12 | ||||
-rw-r--r-- | spec/factories/ml/candidate_params.rb | 10 | ||||
-rw-r--r-- | spec/factories/ml/candidates.rb | 7 | ||||
-rw-r--r-- | spec/factories/ml/experiments.rb | 5 |
4 files changed, 32 insertions, 2 deletions
diff --git a/spec/factories/ml/candidate_metrics.rb b/spec/factories/ml/candidate_metrics.rb new file mode 100644 index 00000000000..28e3974d39f --- /dev/null +++ b/spec/factories/ml/candidate_metrics.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ml_candidate_metrics, class: '::Ml::CandidateMetric' do + association :candidate, factory: :ml_candidates + + sequence(:name) { |n| "metric#{n}" } + value { 2.0 } + step { 1 } + tracked_at { 1234 } + end +end diff --git a/spec/factories/ml/candidate_params.rb b/spec/factories/ml/candidate_params.rb new file mode 100644 index 00000000000..73cb0c54089 --- /dev/null +++ b/spec/factories/ml/candidate_params.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ml_candidate_params, class: '::Ml::CandidateParam' do + association :candidate, factory: :ml_candidates + + sequence(:name) { |n| "metric#{n}" } + sequence(:value) { |n| "value#{n}" } + end +end diff --git a/spec/factories/ml/candidates.rb b/spec/factories/ml/candidates.rb index b5644ee3841..4fbcdc46103 100644 --- a/spec/factories/ml/candidates.rb +++ b/spec/factories/ml/candidates.rb @@ -3,5 +3,12 @@ FactoryBot.define do factory :ml_candidates, class: '::Ml::Candidate' do association :experiment, factory: :ml_experiments association :user + + trait :with_metrics_and_params do + after(:create) do |candidate| + candidate.metrics = FactoryBot.create_list(:ml_candidate_metrics, 2, candidate: candidate ) + candidate.params = FactoryBot.create_list(:ml_candidate_params, 2, candidate: candidate ) + end + end end end diff --git a/spec/factories/ml/experiments.rb b/spec/factories/ml/experiments.rb index 043ca712e60..e4f5a0da6cf 100644 --- a/spec/factories/ml/experiments.rb +++ b/spec/factories/ml/experiments.rb @@ -2,7 +2,8 @@ FactoryBot.define do factory :ml_experiments, class: '::Ml::Experiment' do sequence(:name) { |n| "experiment#{n}" } - association :project - association :user + + project + user end end |