summaryrefslogtreecommitdiff
path: root/spec/models/ci
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/build_spec.rb62
-rw-r--r--spec/models/ci/resource_group_spec.rb88
-rw-r--r--spec/models/ci/resource_spec.rb28
3 files changed, 0 insertions, 178 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 371982df2bb..8a701a461c0 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1275,68 +1275,6 @@ describe Ci::Build do
end
end
- describe '#requires_resource?' do
- subject { build.requires_resource? }
-
- context 'when build needs a resource from a resource group' do
- let(:resource_group) { create(:ci_resource_group, project: project) }
- let(:build) { create(:ci_build, resource_group: resource_group, project: project) }
-
- context 'when build has not retained a resource' do
- it { is_expected.to eq(true) }
- end
-
- context 'when build has retained a resource' do
- before do
- resource_group.retain_resource_for(build)
- end
-
- it { is_expected.to eq(false) }
-
- context 'when ci_resource_group feature flag is disabled' do
- before do
- stub_feature_flags(ci_resource_group: false)
- end
-
- it { is_expected.to eq(false) }
- end
- end
- end
-
- context 'when build does not need a resource from a resource group' do
- let(:build) { create(:ci_build, project: project) }
-
- it { is_expected.to eq(false) }
- end
- end
-
- describe '#retains_resource?' do
- subject { build.retains_resource? }
-
- context 'when build needs a resource from a resource group' do
- let(:resource_group) { create(:ci_resource_group, project: project) }
- let(:build) { create(:ci_build, resource_group: resource_group, project: project) }
-
- context 'when build has retained a resource' do
- before do
- resource_group.retain_resource_for(build)
- end
-
- it { is_expected.to eq(true) }
- end
-
- context 'when build has not retained a resource' do
- it { is_expected.to eq(false) }
- end
- end
-
- context 'when build does not need a resource from a resource group' do
- let(:build) { create(:ci_build, project: project) }
-
- it { is_expected.to eq(false) }
- end
- end
-
describe '#stops_environment?' do
subject { build.stops_environment? }
diff --git a/spec/models/ci/resource_group_spec.rb b/spec/models/ci/resource_group_spec.rb
deleted file mode 100644
index 213a57c2d78..00000000000
--- a/spec/models/ci/resource_group_spec.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Ci::ResourceGroup do
- describe 'validation' do
- it 'valids when key includes allowed character' do
- resource_group = build(:ci_resource_group, key: 'test')
-
- expect(resource_group).to be_valid
- end
-
- it 'invalids when key includes invalid character' do
- resource_group = build(:ci_resource_group, key: ':::')
-
- expect(resource_group).not_to be_valid
- end
- end
-
- describe '#ensure_resource' do
- it 'creates one resource when resource group is created' do
- resource_group = create(:ci_resource_group)
-
- expect(resource_group.resources.count).to eq(1)
- expect(resource_group.resources.all?(&:persisted?)).to eq(true)
- end
- end
-
- describe '#retain_resource_for' do
- subject { resource_group.retain_resource_for(build) }
-
- let(:build) { create(:ci_build) }
- let(:resource_group) { create(:ci_resource_group) }
-
- it 'retains resource for the build' do
- expect(resource_group.resources.first.build).to be_nil
-
- is_expected.to eq(true)
-
- expect(resource_group.resources.first.build).to eq(build)
- end
-
- context 'when there are no free resources' do
- before do
- resource_group.retain_resource_for(create(:ci_build))
- end
-
- it 'fails to retain resource' do
- is_expected.to eq(false)
- end
- end
-
- context 'when the build has already retained a resource' do
- let!(:another_resource) { create(:ci_resource, resource_group: resource_group, build: build) }
-
- it 'fails to retain resource' do
- expect { subject }.to raise_error(ActiveRecord::RecordNotUnique)
- end
- end
- end
-
- describe '#release_resource_from' do
- subject { resource_group.release_resource_from(build) }
-
- let(:build) { create(:ci_build) }
- let(:resource_group) { create(:ci_resource_group) }
-
- context 'when the build has already retained a resource' do
- before do
- resource_group.retain_resource_for(build)
- end
-
- it 'releases resource from the build' do
- expect(resource_group.resources.first.build).to eq(build)
-
- is_expected.to eq(true)
-
- expect(resource_group.resources.first.build).to be_nil
- end
- end
-
- context 'when the build has already released a resource' do
- it 'fails to release resource' do
- is_expected.to eq(false)
- end
- end
- end
-end
diff --git a/spec/models/ci/resource_spec.rb b/spec/models/ci/resource_spec.rb
deleted file mode 100644
index 27e512e2c45..00000000000
--- a/spec/models/ci/resource_spec.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe Ci::Resource do
- describe '.free' do
- subject { described_class.free }
-
- let(:resource_group) { create(:ci_resource_group) }
- let!(:free_resource) { resource_group.resources.take }
- let!(:retained_resource) { create(:ci_resource, :retained, resource_group: resource_group) }
-
- it 'returns free resources' do
- is_expected.to eq([free_resource])
- end
- end
-
- describe '.retained_by' do
- subject { described_class.retained_by(build) }
-
- let(:build) { create(:ci_build) }
- let!(:resource) { create(:ci_resource, build: build) }
-
- it 'returns retained resources' do
- is_expected.to eq([resource])
- end
- end
-end