Skip to content

Commit

Permalink
Split migration spec into separate files
Browse files Browse the repository at this point in the history
Rather than having one huge migration spec file, this keeps it
managable.
  • Loading branch information
ekohl committed Aug 14, 2024
1 parent 5c8cc36 commit 550482e
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 115 deletions.
115 changes: 0 additions & 115 deletions spec/migration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,118 +26,3 @@
end
end
end

migration '20210625142707_dynamic_puppet_in_foreman_groups' do
let(:answers) do
{
'foreman' => {
'user_groups' => ['puppet'],
},
}
end

scenarios %w[foreman katello] do
it 'removes puppet' do
expect(migrated_answers['foreman']['user_groups']).to eq []
end
end
end

migration '200818160950-remove_tuning_fact' do
scenarios %w[foreman-proxy-content] do
let(:config) { super().merge(:facts => { 'tuning' => 'default' }) }

it 'removes facts' do
expect(migrated_config).not_to include(:facts)
end
end
end

migration '20210929144850_disable_puppet_plugins_if_undesired' do
let(:answers) do
{
'foreman' => false,
'foreman::cli' => false,
}
end

scenarios %w[foreman katello] do
it 'keeps foreman::cli disabled' do
expect(migrated_answers['foreman::cli']).to be false
end

it 'adds foreman::cli::puppet disabled' do
expect(migrated_answers['foreman::cli::puppet']).to be false
end

it 'keeps foreman disabled' do
expect(migrated_answers['foreman']).to be false
end

it 'adds foreman::plugin::puppet disabled' do
expect(migrated_answers['foreman::plugin::puppet']).to be false
end
end
end

migration '20211108174119_disable_registration_without_templates' do
scenarios %w[foreman foreman-proxy-content katello] do
context 'with registration, without templates' do
let(:answers) do
{
'foreman_proxy' => {
'registration' => true,
'templates' => false,
},
}
end

it 'disables registration' do
expect(migrated_answers['foreman_proxy']['registration']).to be false
end
end

context 'with registration, with templates' do
let(:answers) do
{
'foreman_proxy' => {
'registration' => true,
'templates' => true,
},
}
end

it 'keeps registration enabled' do
expect(migrated_answers['foreman_proxy']['registration']).to be true
end
end
end
end

migration '181213211252-merged-installer' do
let(:config) { load_fixture_yaml('merged-installer', "#{scenario_name}-before.yaml") }

scenarios %w[foreman-proxy-content katello] do
it 'matches the scenario fixture' do
expect(migrated_config).to eq load_fixture_yaml('merged-installer', "#{scenario_name}-after.yaml")
end
end
end

migration '20231005004305_redis_default_cache' do
scenarios %w[foreman katello] do
context 'changes default cache to Redis' do
let(:answers) do
{
'foreman' => {
'rails_cache_store' => { 'type' => 'file' },
},
}
end

it 'changes the default to Redis' do
expect(migrated_answers['foreman']['rails_cache_store']).to eq({ 'type' => 'redis' })
end
end
end
end
11 changes: 11 additions & 0 deletions spec/migrations/181213211252-merged-installer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

migration '181213211252-merged-installer' do
let(:config) { load_fixture_yaml('merged-installer', "#{scenario_name}-before.yaml") }

scenarios %w[foreman-proxy-content katello] do
it 'matches the scenario fixture' do
expect(migrated_config).to eq load_fixture_yaml('merged-installer', "#{scenario_name}-after.yaml")
end
end
end
11 changes: 11 additions & 0 deletions spec/migrations/200818160950-remove_tuning_fact_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

migration '200818160950-remove_tuning_fact' do
scenarios %w[foreman-proxy-content] do
let(:config) { super().merge(:facts => { 'tuning' => 'default' }) }

it 'removes facts' do
expect(migrated_config).not_to include(:facts)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

migration '20210625142707_dynamic_puppet_in_foreman_groups' do
let(:answers) do
{
'foreman' => {
'user_groups' => ['puppet'],
},
}
end

scenarios %w[foreman katello] do
it 'removes puppet' do
expect(migrated_answers['foreman']['user_groups']).to eq []
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'spec_helper'

migration '20210929144850_disable_puppet_plugins_if_undesired' do
let(:answers) do
{
'foreman' => false,
'foreman::cli' => false,
}
end

scenarios %w[foreman katello] do
it 'keeps foreman::cli disabled' do
expect(migrated_answers['foreman::cli']).to be false
end

it 'adds foreman::cli::puppet disabled' do
expect(migrated_answers['foreman::cli::puppet']).to be false
end

it 'keeps foreman disabled' do
expect(migrated_answers['foreman']).to be false
end

it 'adds foreman::plugin::puppet disabled' do
expect(migrated_answers['foreman::plugin::puppet']).to be false
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require 'spec_helper'

migration '20211108174119_disable_registration_without_templates' do
scenarios %w[foreman foreman-proxy-content katello] do
context 'with registration, without templates' do
let(:answers) do
{
'foreman_proxy' => {
'registration' => true,
'templates' => false,
},
}
end

it 'disables registration' do
expect(migrated_answers['foreman_proxy']['registration']).to be false
end
end

context 'with registration, with templates' do
let(:answers) do
{
'foreman_proxy' => {
'registration' => true,
'templates' => true,
},
}
end

it 'keeps registration enabled' do
expect(migrated_answers['foreman_proxy']['registration']).to be true
end
end
end
end
19 changes: 19 additions & 0 deletions spec/migrations/20231005004305_redis_default_cache_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

migration '20231005004305_redis_default_cache' do
scenarios %w[foreman katello] do
context 'changes default cache to Redis' do
let(:answers) do
{
'foreman' => {
'rails_cache_store' => { 'type' => 'file' },
},
}
end

it 'changes the default to Redis' do
expect(migrated_answers['foreman']['rails_cache_store']).to eq({ 'type' => 'redis' })
end
end
end
end

0 comments on commit 550482e

Please sign in to comment.