[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585
James Turnbull
james at lovedthanlost.net
Fri Jan 23 14:20:45 UTC 2009
The following commit has been merged in the master branch:
commit 2a3d195402900aa31843f7a7ff78026409cf43f5
Author: James Turnbull <james at lovedthanlost.net>
Date: Fri Aug 1 07:11:21 2008 +1000
Specs for yaml indirector .search - I'm still learning!
Updated, I was calling .base myself instead of the actual string
diff --git a/ext/puppetlast b/ext/puppetlast
index 848fdde..d9b698c 100755
--- a/ext/puppetlast
+++ b/ext/puppetlast
@@ -10,33 +10,6 @@ Puppet.parse_config
Puppet[:name] = "puppetmasterd"
Puppet::Node::Facts.terminus_class = :yaml
-print "puppetlast\n"
-
-nodes = {}
-
-yfdir = Puppet.settings.value(:vardir) + "/yaml/facts"
-
-if yfdir
- begin
- Dir.chdir(yfdir) do
- Dir.glob("*.yaml").each do |yaml|
- data = YAML.load_file(yaml)
- t = Time.now
- age = t - data.version
- nodes[data.name] = age.to_i
- end
- end
-
- nodes.sort.each do |node,age|
- minutes = age / 60 + 0.5
- print minutes.floor.to_s + ' minutes ago: ' + node + "\n"
- end
-
- rescue
- print 'error: ' + $! + "\n"
- end
-
Puppet::Node::Facts.search("*").sort.each do |node|
puts "#{node.name} #{node.expired? ? 'cached expired, ' : ''}checked in #{((Time.now - node.values[:_timestamp]) / 60).floor} minutes ago"
end
-
diff --git a/spec/unit/indirector/yaml.rb b/spec/unit/indirector/yaml.rb
index 3875d70..081ae96 100755
--- a/spec/unit/indirector/yaml.rb
+++ b/spec/unit/indirector/yaml.rb
@@ -106,4 +106,33 @@ describe Puppet::Indirector::Yaml, " when choosing file location" do
proc { @store.find(@request) }.should raise_error(Puppet::Error)
end
end
+
+ describe Puppet::Indirector::Yaml, " when searching" do
+ it "should return an array of fact instances with one instance for each file when globbing *" do
+ @request = stub 'request', :key => "*", :instance => @subject
+ @one = mock 'one'
+ @two = mock 'two'
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml two.yaml})
+ YAML.expects(:load_file).with("one.yaml").returns @one;
+ YAML.expects(:load_file).with("two.yaml").returns @two;
+ @store.search(@request).should == [@one, @two]
+ end
+
+ it "should return an array containing a single instance of fact when globbing 'one*'" do
+ @request = stub 'request', :key => "one*", :instance => @subject
+ @one = mock 'one'
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns(%w{one.yaml})
+ YAML.expects(:load_file).with("one.yaml").returns @one;
+ @store.search(@request).should == [@one]
+ end
+
+ it "should return an empty array when the glob doesn't match anything" do
+ @request = stub 'request', :key => "f*ilglobcanfail*", :instance => @subject
+ @store.expects(:base).returns "/my/yaml/dir"
+ Dir.expects(:glob).with(File.join("/my/yaml/dir", @store.class.indirection_name.to_s, @request.key)).returns([])
+ @store.search(@request).should == []
+ end
+ end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list