Skip to content

Commit

Permalink
(MODULES-3953) add acceptance test for manage_repo param
Browse files Browse the repository at this point in the history
This commit adds tests to the acceptance test suite in `class_spec.rb` for
confirming that the manage_repo parameter does, in fact, do what it says.
Specifically, we test that puppet created the repo by applying the
'puppet_agent' class with no params (implying default value of true for
`manage_repo`) and then specifically ensuring the repo present with puppet and
catching (failing) on any resultant changes. Then we remove the repo
configuration and apply the puppet agent class again but with `manage_repo =>
false`, and ensure that the repo configs are not re-created (again by catching
changes).
  • Loading branch information
Moses Mendoza committed Oct 11, 2016
1 parent 676076d commit 9ad396b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,45 @@ class { 'puppet_agent': }
is_expected.to_not match /parser[ ]*=[ ]*future/
}
end

describe 'manage_repo parameter' do
context 'when true (default)' do
it 'should create repo config' do
pp = "class { 'puppet_agent': }"
apply_manifest(pp, :catch_failures => true)
case default['platform']
when /debian|ubuntu/
pp = "include apt\napt::source { 'pc_repo': ensure => present }"
when /fedora|el|centos/
pp = "yumrepo { 'pc_repo': ensure => present }"
else
logger.notify("Cannot manage repo on #{default['platform']}, skipping test 'should create repo config'")
next
end
apply_manifest(pp, :catch_changes => true)
end
end

context 'when false' do
it 'should cease to manage repo config' do
pp = "class { 'puppet_agent': }"
apply_manifest(pp, :catch_failures => true)
case default['platform']
when /debian|ubuntu/
pp = "include apt\napt::source { 'pc_repo': ensure => absent }"
when /fedora|el|centos/
pp = "yumrepo { 'pc_repo': ensure => absent }"
else
logger.notify("Cannot manage repo on #{default['platform']}, skipping test 'should cease to manage repo config'")
next
end
apply_manifest(pp, :catch_failures => true)
pp = "class { 'puppet_agent': manage_repo => false }"
# expect no changes now that repo is unmanaged
apply_manifest(pp, :catch_changes => true)
end
end
end
end

context 'no services enabled on install' do
Expand Down

0 comments on commit 9ad396b

Please sign in to comment.