debian-mirror-gitlab/spec/models/ci/runner_version_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.6 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Ci::RunnerVersion, feature_category: :runner_fleet do
2023-04-23 21:23:45 +05:30
let_it_be(:runner_version_upgrade_recommended) do
2023-03-04 22:38:38 +05:30
create(:ci_runner_version, version: 'abc234', status: :recommended)
end
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
let_it_be(:runner_version_upgrade_unavailable) do
create(:ci_runner_version, version: 'abc123', status: :unavailable)
2022-08-13 15:12:31 +05:30
end
2023-06-20 00:43:36 +05:30
it { is_expected.to have_many(:runner_managers).with_foreign_key(:version) }
2023-04-23 21:23:45 +05:30
2023-03-04 22:38:38 +05:30
it_behaves_like 'having unique enum values'
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
describe '.unavailable' do
subject { described_class.unavailable }
2022-08-13 15:12:31 +05:30
2023-04-23 21:23:45 +05:30
it { is_expected.to match_array([runner_version_upgrade_unavailable]) }
2022-08-13 15:12:31 +05:30
end
describe '.potentially_outdated' do
subject { described_class.potentially_outdated }
let_it_be(:runner_version_nil) { create(:ci_runner_version, version: 'abc345', status: nil) }
2023-04-23 21:23:45 +05:30
let_it_be(:runner_version_upgrade_available) do
2022-08-13 15:12:31 +05:30
create(:ci_runner_version, version: 'abc456', status: :available)
end
2022-08-27 11:52:29 +05:30
it 'contains any valid or unprocessed runner version that is not already recommended' do
2023-03-04 22:38:38 +05:30
is_expected.to match_array(
2023-04-23 21:23:45 +05:30
[runner_version_nil, runner_version_upgrade_unavailable, runner_version_upgrade_available]
2023-03-04 22:38:38 +05:30
)
2022-08-13 15:12:31 +05:30
end
end
describe 'validation' do
2023-03-17 16:20:25 +05:30
it { is_expected.to validate_length_of(:version).is_at_most(2048) }
2022-08-13 15:12:31 +05:30
end
2023-05-27 22:25:52 +05:30
describe '#status' do
context 'when is not processed' do
subject(:ci_runner_version) { create(:ci_runner_version, version: 'abc124', status: :not_processed) }
let(:attr) { :status }
let(:attr_value) { :not_processed }
it_behaves_like 'having enum with nil value'
end
end
2022-08-13 15:12:31 +05:30
end