-
Notifications
You must be signed in to change notification settings - Fork 181
Fixes issues due to serverspec upgrade #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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 } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did the serverspec update fix this on solaris 10?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, it works, I have tested it against solaris 10, it was the grep that was broken, its(:content) does not use the multiline grep so with a regex it matches.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should contain still uses the specinfra matcher, however the serverspec its(:content) would use the https://github.com/serverspec/serverspec/blob/5b7e90f259305726527253744f7a0feb3de1cae4/lib/serverspec/type/file.rb#L97-L102 and read as a string and then use rspec match regex to match the multiline string. |
||
| 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 | ||
|
|
@@ -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/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is there an extra
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every time I ran it with a regex it was reporting two returns. Not sure if the grep was reporting differently or stdout, but it was consistent with all platforms on that failure. Tested on CentOS 6, Win 2008/2012 and Solaris 10. |
||
| 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 | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
||
|
|
@@ -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 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to leave pry in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes