Welcome to mirror list, hosted at ThFree Co, Russian Federation.

api_helpers_spec.rb « mlflow « ml « api « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e7a0187d86ee5376e683470d627d939c1342bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe API::Ml::Mlflow::ApiHelpers, feature_category: :mlops do
  include described_class

  describe '#candidates_order_params' do
    using RSpec::Parameterized::TableSyntax

    subject { candidates_order_params(params) }

    where(:input, :order_by, :order_by_type, :sort) do
      ''                            | nil          | nil      | nil
      'created_at'                  | 'created_at' | 'column' | nil
      'created_at ASC'              | 'created_at' | 'column' | 'ASC'
      'metrics.something'           | 'something'  | 'metric' | nil
      'metrics.something asc'       | 'something'  | 'metric' | 'asc'
      'metrics.something.blah asc'  | 'something'  | 'metric' | 'asc'
      'params.something ASC'        | nil          | nil      | 'ASC'
      'metadata.something ASC'      | nil          | nil      | 'ASC'
    end
    with_them do
      let(:params) { { order_by: input } }

      it 'is correct' do
        is_expected.to include({ order_by: order_by, order_by_type: order_by_type, sort: sort })
      end
    end
  end

  describe '#model_order_params' do
    using RSpec::Parameterized::TableSyntax

    subject { model_order_params(params) }

    where(:input, :order_by, :sort) do
      ''                            | 'name'        | 'asc'
      'name'                        | 'name'        | 'asc'
      'name DESC'                   | 'name'        | 'desc'
      'last_updated_timestamp'      | 'updated_at'  | 'asc'
      'last_updated_timestamp asc'  | 'updated_at'  | 'asc'
      'last_updated_timestamp DESC' | 'updated_at'  | 'desc'
    end
    with_them do
      let(:params) { { order_by: input } }

      it 'is correct' do
        is_expected.to include({ order_by: order_by, sort: sort })
      end
    end
  end

  describe '#model_filter_params' do
    using RSpec::Parameterized::TableSyntax

    subject { model_filter_params(params) }

    where(:input, :output) do
      ''                            | {}
      'name=""'                     | { name: '' }
      'name=foo'                    | { name: 'foo' }
      'name="foo"'                  | { name: 'foo' }
      'invalid="foo"'               | {}
    end
    with_them do
      let(:params) { { filter: input } }

      it 'is correct' do
        is_expected.to eq(output)
      end
    end
  end
end