2019-12-19 10:07:55 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe Ci::Resource do
|
2019-12-19 10:07:55 -05:00
|
|
|
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) }
|
2021-02-01 04:09:28 -05:00
|
|
|
let!(:resource) { create(:ci_resource, processable: build) }
|
2019-12-19 10:07:55 -05:00
|
|
|
|
|
|
|
it 'returns retained resources' do
|
|
|
|
is_expected.to eq([resource])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|