Skip to content

Commit

Permalink
Update inifile to 606de69
Browse files Browse the repository at this point in the history
606de69 Merge pull request redhat-openstack#147 from cyberious/SpecinfraUpgrade
4dfb8e1 Force acceptance test ordering with require and before
8867610 Merge pull request redhat-openstack#146 from cyberious/SpecinfraUpgrade
8e2689b Fixes issues due to serverspec upgrade and usage of obsolete should contain method for files
03417e5 Merge pull request redhat-openstack#144 from cmurphy/rspec
f84f058 Pin rspec gems

Signed-off-by: Gael Chamoulaud <[email protected]>
  • Loading branch information
strider committed Feb 19, 2015
1 parent e2d0692 commit 55a5160
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 88 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod 'horizon',
:git => 'https://github.com/stackforge/puppet-horizon.git'

mod 'inifile',
:commit => 'be5fc47f00466a2e6293145b3a0d4fcb586bcf15',
:commit => '606de6971d019fa9557d0866e90942a3d6e06a97',
:git => 'https://github.com/puppetlabs/puppetlabs-inifile.git'

mod 'ipa',
Expand Down
10 changes: 8 additions & 2 deletions inifile/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@ end

group :development, :unit_tests do
gem 'rake', :require => false
gem 'rspec-puppet', :require => false
gem 'rspec-core', '3.1.7', :require => false
gem 'rspec-puppet', '~> 1.0', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'simplecov', :require => false
gem 'puppet_facts', :require => false
gem 'json', :require => false
gem 'pry', :require => false
end

beaker_version = ENV['BEAKER_VERSION']
beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION']
group :system_tests do
if beaker_version
gem 'beaker', *location_for(beaker_version)
end
if beaker_rspec_version
gem 'beaker-rspec', *location_for(beaker_rspec_version)
else
else
gem 'beaker-rspec', :require => false
end
gem 'serverspec', :require => false
Expand Down
83 changes: 42 additions & 41 deletions inifile/spec/acceptance/ini_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

describe 'ini_setting resource' do
after :all do
shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0,1,2])
shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0, 1, 2])
end

shared_examples 'has_content' do |path,pp,content|
shared_examples 'has_content' do |path, pp, content|
before :all do
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end
after :all do
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end

it 'applies the manifest twice' do
Expand All @@ -23,20 +23,17 @@

describe file(path) do
it { should be_file }
#XXX Solaris 10 doesn't support multi-line grep
it("should contain #{content}", :unless => fact('osfamily') == 'Solaris') {
should contain(content)
}
its(:content) { should match content }
end
end

shared_examples 'has_error' do |path,pp,error|
shared_examples 'has_error' do |path, pp, error|
before :all do
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end
after :all do
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end

it 'applies the manifest and gets a failure message' do
Expand Down Expand Up @@ -72,13 +69,13 @@
apply_manifest(pp, :catch_changes => true)
end

it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, "four = five\n[one]\ntwo = three"
it_behaves_like 'has_content', "#{tmpdir}/ini_setting.ini", pp, /four = five\n\n\[one\]\ntwo = three/
end

context '=> absent for key/value' do
before :all do
if fact('osfamily') == 'Darwin'
shell("echo \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
shell("echo \"four = five[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
else
shell("echo -e \"four = five\n[one]\ntwo = three\" > #{tmpdir}/ini_setting.ini")
end
Expand All @@ -96,14 +93,16 @@

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_setting.ini") do
it { should be_file }
it { should contain('four = five') }
it { should contain('[one]') }
it { should_not contain('two = three') }
its(:content) {
should match /four = five/
should match /\[one\]/
should_not match /two = three/
}
end
end

Expand All @@ -116,8 +115,8 @@
end
end
after :all do
shell("cat #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2])
shell("rm #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0,1,2])
shell("cat #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{tmpdir}/ini_setting.ini", :acceptable_exit_codes => [0, 1, 2])
end

pp = <<-EOS
Expand All @@ -132,23 +131,25 @@

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_setting.ini") do
it { should be_file }
it { should_not contain('four = five') }
it { should contain('[one]') }
it { should contain('two = three') }
its(:content) {
should_not match /four = five/
should match /\[one\]/
should match /two = three/
}
end
end
end

describe 'section, setting, value parameters' do
{
"section => 'test', setting => 'foo', value => 'bar'," => "[test]\nfoo = bar",
"section => 'more', setting => 'baz', value => 'quux'," => "[more]\nbaz = quux",
"section => '', setting => 'top', value => 'level'," => "top = level",
"section => 'test', setting => 'foo', value => 'bar'," => /\[test\]\nfoo = bar/,
"section => 'more', setting => 'baz', value => 'quux'," => /\[more\]\nbaz = quux/,
"section => '', setting => 'top', value => 'level'," => /top = level/,
}.each do |parameter_list, content|
context parameter_list do
pp = <<-EOS
Expand All @@ -164,12 +165,12 @@
end

{
"section => 'test'," => /setting is a required.+value is a required/,
"setting => 'foo', value => 'bar'," => /section is a required/,
"section => 'test', setting => 'foo'," => /value is a required/,
"section => 'test', value => 'bar'," => /setting is a required/,
"value => 'bar'," => /section is a required.+setting is a required/,
"setting => 'foo'," => /section is a required.+value is a required/,
"section => 'test'," => /setting is a required.+value is a required/,
"setting => 'foo', value => 'bar'," => /section is a required/,
"section => 'test', setting => 'foo'," => /value is a required/,
"section => 'test', value => 'bar'," => /setting is a required/,
"value => 'bar'," => /section is a required.+setting is a required/,
"setting => 'foo'," => /section is a required.+value is a required/,
}.each do |parameter_list, error|
context parameter_list, :pending => 'no error checking yet' do
pp = <<-EOS
Expand All @@ -187,9 +188,9 @@

describe 'path parameter' do
[
"#{tmpdir}/one.ini",
"#{tmpdir}/two.ini",
"#{tmpdir}/three.ini",
"#{tmpdir}/one.ini",
"#{tmpdir}/two.ini",
"#{tmpdir}/three.ini",
].each do |path|
context "path => #{path}" do
pp = <<-EOS
Expand All @@ -202,7 +203,7 @@
}
EOS

it_behaves_like 'has_content', path, pp, "[one]\ntwo = three"
it_behaves_like 'has_content', path, pp, /\[one\]\ntwo = three/
end
end

Expand All @@ -223,9 +224,9 @@

describe 'key_val_separator parameter' do
{
"" => "two = three",
"key_val_separator => '='," => "two=three",
"key_val_separator => ' = '," => "two = three",
"" => /two = three/,
"key_val_separator => '='," => /two=three/,
"key_val_separator => ' = '," => /two = three/,
}.each do |parameter, content|
context "with \"#{parameter}\" makes \"#{content}\"" do
pp = <<-EOS
Expand Down
73 changes: 39 additions & 34 deletions inifile/spec/acceptance/ini_subsetting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,38 @@

describe 'ini_subsetting resource' do
after :all do
shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0,1,2])
shell("rm #{tmpdir}/*.ini", :acceptable_exit_codes => [0, 1, 2])
end

shared_examples 'has_content' do |path,pp,content|
shared_examples 'has_content' do |path, pp, content|
before :all do
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end
after :all do
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file(path) do
it { should be_file }
it { should contain(content) }
its(:content) {
should match content
}
end
end

shared_examples 'has_error' do |path,pp,error|
shared_examples 'has_error' do |path, pp, error|
before :all do
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end
after :all do
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end

it 'applies the manifest and gets a failure message' do
Expand Down Expand Up @@ -63,19 +65,19 @@
setting => 'key',
subsetting => 'beta',
value => 'trons',
require => Ini_subsetting['ensure => present for alpha'],
}
EOS

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_subsetting.ini") do
it { should be_file }
#XXX Solaris 10 doesn't support multi-line grep
it("should contain [one]\nkey = alphabet betatrons", :unless => fact('osfamily') == 'Solaris') {
should contain("[one]\nkey = alphabet betatrons")
its(:content) {
should match /\[one\]\nkey = alphabet betatrons/
}
end
end
Expand All @@ -101,27 +103,27 @@

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_subsetting.ini") do
it { should be_file }
it { should contain('[one]') }
it { should contain('key = betatrons') }
it { should_not contain('alphabet') }
its(:content) {
should match /\[one\]/
should match /key = betatrons/
should_not match /alphabet/
}
end
end
end

describe 'subsetting_separator' do
{
"" => "two = twinethree foobar",
#"subsetting_separator => ''," => "two = twinethreefoobar", # breaks regex
"subsetting_separator => ','," => "two = twinethree,foobar",
"subsetting_separator => ' '," => "two = twinethree foobar",
"subsetting_separator => ' == '," => "two = twinethree == foobar",
"subsetting_separator => '='," => "two = twinethree=foobar",
#"subsetting_separator => '---'," => "two = twinethree---foobar", # breaks regex
"" => /two = twinethree foobar/,
"subsetting_separator => ','," => /two = twinethree,foobar/,
"subsetting_separator => ' '," => /two = twinethree foobar/,
"subsetting_separator => ' == '," => /two = twinethree == foobar/,
"subsetting_separator => '='," => /two = twinethree=foobar/,
}.each do |parameter, content|
context "with \"#{parameter}\" makes \"#{content}\"" do
pp = <<-EOS
Expand All @@ -132,6 +134,7 @@
subsetting => 'twine',
value => 'three',
path => "#{tmpdir}/subsetting_separator.ini",
before => Ini_subsetting['foobar'],
#{parameter}
}
ini_subsetting { "foobar":
Expand All @@ -152,10 +155,10 @@

describe 'quote_char' do
{
['-Xmx'] => 'args=""',
['-Xmx', '256m'] => 'args=-Xmx256m',
['-Xmx', '512m'] => 'args="-Xmx512m"',
['-Xms', '256m'] => 'args="-Xmx256m -Xms256m"',
['-Xmx'] => /args=""/,
['-Xmx', '256m'] => /args=-Xmx256m/,
['-Xmx', '512m'] => /args="-Xmx512m"/,
['-Xms', '256m'] => /args="-Xmx256m -Xms256m"/,
}.each do |parameter, content|
context %Q{with '#{parameter.first}' #{parameter.length > 1 ? '=> \'' << parameter[1] << '\'' : 'absent'} makes '#{content}'} do
path = File.join(tmpdir, 'ini_subsetting.ini')
Expand All @@ -164,8 +167,8 @@
shell(%Q{echo '[java]\nargs=-Xmx256m' > #{path}})
end
after :all do
shell("cat #{path}", :acceptable_exit_codes => [0,1,2])
shell("rm #{path}", :acceptable_exit_codes => [0,1,2])
shell("cat #{path}", :acceptable_exit_codes => [0, 1, 2])
shell("rm #{path}", :acceptable_exit_codes => [0, 1, 2])
end

pp = <<-EOS
Expand All @@ -182,12 +185,14 @@

it 'applies the manifest twice' do
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
apply_manifest(pp, :catch_changes => true)
end

describe file("#{tmpdir}/ini_subsetting.ini") do
it { should be_file }
it { should contain(content) }
its(:content) {
should match content
}
end
end
end
Expand Down
Loading

0 comments on commit 55a5160

Please sign in to comment.