Skip to content

Commit

Permalink
Merge pull request #664 from joshcooper/delete_dup_test
Browse files Browse the repository at this point in the history
(maint) Delete duplicate test
  • Loading branch information
joshcooper authored Aug 30, 2023
2 parents ac83d4f + 7935c79 commit 04bee65
Showing 1 changed file with 4 additions and 61 deletions.
65 changes: 4 additions & 61 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@

describe 'puppet_agent class' do
context 'default parameters in apply' do
before(:all) { setup_puppet_on default }
after(:all) { teardown_puppet_on default }

it 'works idempotently with no errors' do
pp = <<-EOS
class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }
EOS

before(:all) do
setup_puppet_on default
pp = "class { 'puppet_agent': package_version => 'auto'}"
apply_manifest(pp, catch_failures: true)
wait_for_finish_on default
configure_agent_on default
# Run three times to ensure idempotency if upgrading with the package resource (MODULES-10666)
unless %r{solaris-10|aix|osx|windows}i.match?(default['platform'])
apply_manifest(pp, expect_changes: true)
wait_for_finish_on default
end
apply_manifest(pp, catch_changes: true)
end
after(:all) { teardown_puppet_on default }

describe package(package_name(default)) do
it { is_expected.to be_installed }
Expand Down Expand Up @@ -50,9 +38,6 @@ class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }
describe 'manage_repo parameter' do
context 'when true (default)' do
it 'creates repo config' do
pp = "class { 'puppet_agent': }"
apply_manifest(pp, catch_failures: true)
wait_for_finish_on default
case default['platform']
when %r{debian|ubuntu}
pp = "include apt\napt::source { 'pc_repo': ensure => present, location => 'https://apt.puppet.com', repos => 'puppet5'}"
Expand All @@ -69,9 +54,6 @@ class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5' }

context 'when false' do
it 'ceases to manage repo config' do
pp = "class { 'puppet_agent': }"
apply_manifest(pp, catch_failures: true)
wait_for_finish_on default
case default['platform']
when %r{debian|ubuntu}
pp = "include apt\napt::source { 'pc_repo': ensure => absent }"
Expand Down Expand Up @@ -117,43 +99,4 @@ class { 'puppet_agent': service_names => [] }
it { is_expected.not_to be_running }
end
end

unless %r{windows}i.match?(default['platform'])
unless %r{solaris-10|aix|osx|windows}i.match?(default['platform'])
context 'on platforms managed with the package resource' do
before(:all) { setup_puppet_on default }

after(:all) do
on default, 'rm -f /tmp/a'
teardown_puppet_on default
end

let(:manifest) do
<<-EOS
class { 'puppet_agent': package_version => '5.5.21', collection => 'puppet5', before => File['/tmp/a'] }
file { '/tmp/a': ensure => 'present' }
EOS
end

it 'upgrades the agent on the first run' do
# First run should upgrade the agent
apply_manifest(manifest, expect_changes: true)
configure_agent_on default
expect(package(package_name(default))).to be_installed
expect(file('/tmp/a')).not_to exist
end

it 'evaluates remanining resources on the second run' do
# Second run should apply the file resource
apply_manifest(manifest, expect_changes: true)
expect(file('/tmp/a')).to exist
end

it 'does nothing on future runs' do
# Third run should not do anything
apply_manifest(manifest, catch_changes: true)
end
end
end
end
end

0 comments on commit 04bee65

Please sign in to comment.