Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

Is it possible to clear catalog cache in rspec-puppet

$
0
0
Hi, I have below manifests class module_name { if str2bool("$::is_virtual") == true { $p1 = 'package-name' if $::operatingsystemmajrelease < '7' { package {["${p1}-pae"]: ensure => installed } } else { package {$p1: ensure => installed } } } } } rspec-puppet test is, require 'spec_helper' describe 'module_name' do it { should contain_class('module_name') } osver = '5' if osver < '7' p1 = 'package-name' it { should contain_package("#{p1}-pae").with_ensure('installed')} end if osver == '7' p1 = 'package-name' it { should contain_package(p1).with_ensure('installed')} end end The above test case worked with out any issues. But if I change the value to osver = '7', getting below error Failure/Error: it { should contain_package('package-name').with_ensure('installed')} expected that the catalogue would contain Package[package-name] I know the cause of the error, because rspec-puppet will only re-compile the catalog there are changes in facts or variable. But it won't be satisfied because the catalog was already compiled for a previous test, so its not accepting the changed value test case. so, is there any option to clear the previously compiled test case catalog and re-compile the catalog if we cahnge any "if condition" or facts. I know about mock function, but it works only for custom function and hiera. Do we have any other alternate for my test case.

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>