diff options
Diffstat (limited to 'spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_ml_candidates_metric_spec.rb')
-rw-r--r-- | spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_ml_candidates_metric_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_ml_candidates_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_ml_candidates_metric_spec.rb new file mode 100644 index 00000000000..e5026ab6358 --- /dev/null +++ b/spec/lib/gitlab/usage/metrics/instrumentations/count_projects_with_ml_candidates_metric_spec.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountProjectsWithMlCandidatesMetric, + feature_category: :mlops do + let_it_be(:project_without_candidates) { create(:project, :repository) } + let_it_be(:candidate) { create(:ml_candidates) } + let_it_be(:another_candidate) { create(:ml_candidates, experiment: candidate.experiment) } + + let(:expected_value) { 1 } + let(:expected_query) do + 'SELECT COUNT(DISTINCT "ml_experiments"."ml_experiments.project_id") FROM "ml_experiments" WHERE ' \ + '(EXISTS (SELECT 1 FROM "ml_candidates" WHERE ("ml_experiments"."id" = "ml_candidates"."experiment_id")))' + end + + it_behaves_like 'a correct instrumented metric value and query', { time_frame: 'all' } +end |