Last active
January 4, 2016 06:09
-
-
Save fatmcgav/8580513 to your computer and use it in GitHub Desktop.
Failing Autorequires test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Type.newtype(:domain) do | |
@doc = "Manage Glassfish domains" | |
ensurable | |
... | |
# Autorequire the user running command | |
autorequire(:user) do | |
self[:user] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe Puppet::Type.type(:domain) do | |
... | |
describe "autorequire" do | |
let :domain do | |
described_class.new( | |
:domainname => 'test', | |
:user => 'glassfish', | |
:passwordfile => '/tmp/asadmin.pass' | |
) | |
end | |
# Need to include glassfish to get user resource | |
let :userprovider do | |
Puppet::Type.type(:user).provide(:fake_user_provider) { mk_resource_methods } | |
end | |
let :user do | |
Puppet::Type.type(:user).new( | |
:name => 'glassfish', | |
:ensure => 'present' | |
) | |
end | |
let :catalog do | |
Puppet::Resource::Catalog.new | |
end | |
before :each do | |
Puppet::Type.type(:user).stubs(:defaultprovider).returns userprovider | |
File.expects(:exists?).with('/tmp/asadmin.pass').returns(true).once | |
Puppet.features.expects(:root?).returns(true) | |
end | |
it "should not autorequire a user when no matching user can be found" do | |
catalog.add_resource domain | |
domain.autorequire.should be_empty | |
end | |
it "should autorequire a matching user" do | |
catalog.add_resource domain | |
catalog.add_resource user | |
reqs = domain.autorequire | |
reqs.size.should == 1 | |
reqs[0].source.ref.should == user.ref | |
reqs[0].target.ref.should == domain.ref | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
should autorequire a matching user (FAILED - 1) | |
Failures: | |
1) Puppet::Type::Domain when validating values autorequire should autorequire a matching user | |
Failure/Error: reqs[0].source.must == user | |
NoMethodError: | |
undefined method `must' for #<Puppet::Type::User:0x7f92f9cfaa38> | |
# ./spec/unit/puppet/type/domain_spec.rb:210 | |
Finished in 11.85 seconds | |
81 examples, 1 failure | |
Failed examples: | |
rspec ./spec/unit/puppet/type/domain_spec.rb:205 # Puppet::Type::Domain when validating values autorequire should autorequire a matching user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment