diff options
author | Josh Cooper <josh@puppetlabs.com> | 2011-07-18 23:40:17 -0700 |
---|---|---|
committer | Jacob Helwig <jacob@puppetlabs.com> | 2011-08-19 13:48:29 -0700 |
commit | 5d3a40fda87b7346d99fd25c0eb1906a62c19512 (patch) | |
tree | 9dbdeda33b6e19cd26b0b3735694f26473d258e6 /spec | |
parent | ce0c258ba24a5232a82a69eb62387893feca684e (diff) | |
download | puppet-5d3a40fda87b7346d99fd25c0eb1906a62c19512.tar.gz puppet-5d3a40fda87b7346d99fd25c0eb1906a62c19512.tar.xz puppet-5d3a40fda87b7346d99fd25c0eb1906a62c19512.zip |
Maint: Fix miscellaneous tests
Several tests were broken due to pecularities of Windows
and Ruby on Windows:
* Ruby on windows does not differentiate between group and
other file permissions.
* All open file handles must be closed before the file can
be deleted
* Sometimes the current working directory (Dir.getwd) is
reported as C:/foo and other times as C:\\foo, which
confuses the spec tests.
* Ruby's sprintf formats floating point values differently
on Windows vs Unix. The Windows exponent has an extra
leading zero.
* Needed to stub execution of security command with the
SMF service provider.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
(cherry picked from commit 0e4ae653c0628cb0df9ccace98bca4bc7478fb7c)
Diffstat (limited to 'spec')
-rwxr-xr-x | spec/integration/util/settings_spec.rb | 4 | ||||
-rwxr-xr-x | spec/unit/application/inspect_spec.rb | 1 | ||||
-rwxr-xr-x | spec/unit/parser/functions/sprintf_spec.rb | 3 | ||||
-rwxr-xr-x | spec/unit/provider/macauthorization_spec.rb | 5 | ||||
-rwxr-xr-x | spec/unit/provider/service/smf_spec.rb | 1 | ||||
-rwxr-xr-x | spec/unit/type/file/content_spec.rb | 1 |
6 files changed, 12 insertions, 3 deletions
diff --git a/spec/integration/util/settings_spec.rb b/spec/integration/util/settings_spec.rb index b05c63107..46d783c4e 100755 --- a/spec/integration/util/settings_spec.rb +++ b/spec/integration/util/settings_spec.rb @@ -18,12 +18,12 @@ describe Puppet::Util::Settings do File.should be_directory(settings[:maindir]) end - it "should make its directories with the corret modes" do + it "should make its directories with the correct modes" do settings = Puppet::Util::Settings.new settings.setdefaults :main, minimal_default_settings.update( :maindir => {:default => tmpfile("main"), :desc => "a", :mode => 0750} ) settings.use(:main) - (File.stat(settings[:maindir]).mode & 007777).should == 0750 + (File.stat(settings[:maindir]).mode & 007777).should == (Puppet.features.microsoft_windows? ? 0755 : 0750) end end diff --git a/spec/unit/application/inspect_spec.rb b/spec/unit/application/inspect_spec.rb index 630470dc4..be5887f01 100755 --- a/spec/unit/application/inspect_spec.rb +++ b/spec/unit/application/inspect_spec.rb @@ -103,6 +103,7 @@ describe Puppet::Application::Inspect do catalog = Puppet::Resource::Catalog.new file = Tempfile.new("foo") resource = Puppet::Resource.new(:file, file.path, :parameters => {:audit => "all"}) + file.close file.delete catalog.add_resource(resource) Puppet::Resource::Catalog::Yaml.any_instance.stubs(:find).returns(catalog) diff --git a/spec/unit/parser/functions/sprintf_spec.rb b/spec/unit/parser/functions/sprintf_spec.rb index bd4863f23..3351c7fb3 100755 --- a/spec/unit/parser/functions/sprintf_spec.rb +++ b/spec/unit/parser/functions/sprintf_spec.rb @@ -30,7 +30,8 @@ describe "the sprintf function" do it "should format large floats" do result = @scope.function_sprintf(["%+.2e", "27182818284590451"]) - result.should(eql("+2.72e+16")) + str = Puppet.features.microsoft_windows? ? "+2.72e+016" : "+2.72e+16" + result.should(eql(str)) end it "should perform more complex formatting" do diff --git a/spec/unit/provider/macauthorization_spec.rb b/spec/unit/provider/macauthorization_spec.rb index a76f917f7..dbe36a04b 100755 --- a/spec/unit/provider/macauthorization_spec.rb +++ b/spec/unit/provider/macauthorization_spec.rb @@ -106,6 +106,11 @@ describe provider_class do end it "should call the internal method set_right" do + @provider.expects(:execute).with { |cmds, args| + cmds.include?("read") and + cmds.include?(@authname) and + args[:combine] == false + }.once @provider.expects(:set_right) @provider.flush end diff --git a/spec/unit/provider/service/smf_spec.rb b/spec/unit/provider/service/smf_spec.rb index 5212d540a..fd7d50e3a 100755 --- a/spec/unit/provider/service/smf_spec.rb +++ b/spec/unit/provider/service/smf_spec.rb @@ -111,6 +111,7 @@ describe provider_class do it "should import the manifest if service is missing" do @provider.expects(:svccfg).with(:import, "/tmp/myservice.xml") @provider.expects(:texecute).with(:start, ["/usr/sbin/svcadm", :enable, "/system/myservice"], true) + @provider.expects(:svcs).with('-H', '-o', 'state,nstate', "/system/myservice").returns("online\t-") @provider.start end diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb index 6a2f3f4b3..04ec48555 100755 --- a/spec/unit/type/file/content_spec.rb +++ b/spec/unit/type/file/content_spec.rb @@ -254,6 +254,7 @@ describe content do @content.should = "{md5}foo" @content.resource.bucket.class.any_instance.stubs(:getfile).returns "foo" @content.write(@fh) + @fh.close end describe "from actual content" do |