blob: 6ddae20f8d63309aa1749e911a709dc6704a0e08 (
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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ml::FindOrCreateModelService, feature_category: :mlops do
let_it_be(:existing_model) { create(:ml_models) }
let_it_be(:another_project) { create(:project) }
subject(:create_model) { described_class.new(project, name).execute }
describe '#execute' do
context 'when model name does not exist in the project' do
let(:name) { 'new_model' }
let(:project) { existing_model.project }
it 'creates a model', :aggregate_failures do
expect { create_model }.to change { Ml::Model.count }.by(1)
expect(create_model.name).to eq(name)
end
end
context 'when model name exists but project is different' do
let(:name) { existing_model.name }
let(:project) { another_project }
it 'creates a model', :aggregate_failures do
expect { create_model }.to change { Ml::Model.count }.by(1)
expect(create_model.name).to eq(name)
end
end
context 'when model with name exists' do
let(:name) { existing_model.name }
let(:project) { existing_model.project }
it 'fetches existing model', :aggregate_failures do
expect { create_model }.to change { Ml::Model.count }.by(0)
expect(create_model).to eq(existing_model)
end
end
end
end
|