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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
# 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
describe '#gitlab_tags' do
describe 'when tags param is not supplied' do
let(:params) { {} }
it 'returns nil' do
expect(gitlab_tags).to be nil
end
end
describe 'when tags param is supplied' do
let(:params) { { tags: input } }
using RSpec::Parameterized::TableSyntax
subject { gitlab_tags }
where(:input, :output) do
[] | nil
[{}] | {}
[{ key: 'foo', value: 'bar' }] | {}
[{ key: "gitlab.version", value: "1.2.3" }] | { "version" => "1.2.3" }
[{ key: "foo", value: "bar" }, { key: "gitlab.foo", value: "baz" }] | { "foo" => "baz" }
end
with_them do
it 'is correct' do
is_expected.to eq(output)
end
end
end
end
describe '#custom_version' do
using RSpec::Parameterized::TableSyntax
subject { custom_version }
where(:input, :output) do
[] | nil
[{}] | nil
[{ key: 'foo', value: 'bar' }] | nil
[{ key: "gitlab.version", value: "1.2.3" }] | "1.2.3"
[{ key: "foo", value: "bar" }, { key: "gitlab.foo", value: "baz" }] | nil
end
with_them do
let(:params) { { tags: input } }
it 'is correct' do
is_expected.to eq(output)
end
end
end
end
|