summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-03-07 16:42:53 -0800
committerNick Lewis <nick@puppetlabs.com>2011-03-08 15:42:27 -0800
commitf83636698229241b2ab35849437f3e515f6ac5c1 (patch)
tree1973c4fe7178f3330151ba59c80ec63089d9f314 /spec
parent8ce30c83ddba87ba7e2622a46f27143159132789 (diff)
downloadpuppet-f83636698229241b2ab35849437f3e515f6ac5c1.tar.gz
puppet-f83636698229241b2ab35849437f3e515f6ac5c1.tar.xz
puppet-f83636698229241b2ab35849437f3e515f6ac5c1.zip
(#6338) Implement search for InventoryActiveRecord facts terminus
Paired-With: Max Martin Reviewed-By: Jacob Helwig
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/indirector/facts/inventory_active_record_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/unit/indirector/facts/inventory_active_record_spec.rb b/spec/unit/indirector/facts/inventory_active_record_spec.rb
index b97bada19..7fb55561d 100644
--- a/spec/unit/indirector/facts/inventory_active_record_spec.rb
+++ b/spec/unit/indirector/facts/inventory_active_record_spec.rb
@@ -95,5 +95,57 @@ describe "Puppet::Node::Facts::InventoryActiveRecord", :if => (Puppet.features.r
Puppet::Node::Facts.find("array").values["fact1"].should == "value1"
end
end
+
+ describe "#search" do
+
+ it "should return node names that match 'equal' constraints" do
+ Puppet::Node::Facts.new("foo", "fact1" => "value1", "fact2" => "value2", "fact3" => "value3").save
+ Puppet::Node::Facts.new("bar", "fact1" => "value2").save
+ Puppet::Node::Facts.new("baz", "fact1" => "value1", "fact2" => "value1", "fact3" => "value1").save
+
+ request = Puppet::Indirector::Request.new(:facts, :search, nil,
+ {'facts.fact1.eq' => 'value1',
+ 'facts.fact2.eq' => 'value2',
+ 'facts.fact3.eq' => 'value3'})
+ terminus.search(request).should =~ ["foo"]
+ end
+
+ it "should return node names that match 'not equal' constraints" do
+ Puppet::Node::Facts.new("foo", "fact1" => "value1", "fact2" => "value2", "fact3" => "value3").save
+ Puppet::Node::Facts.new("bar", "fact1" => "value2").save
+ Puppet::Node::Facts.new("baz", "fact1" => "value1", "fact2" => "value1", "fact3" => "value1").save
+ Puppet::Node::Facts.new("bang", "fact1" => "value1", "fact2" => "value2", "fact3" => "value1").save
+
+ request = Puppet::Indirector::Request.new(:facts, :search, nil,
+ {'facts.fact1.ne' => 'value3',
+ 'facts.fact2.ne' => 'value1',
+ 'facts.fact3.ne' => 'value2'})
+ terminus.search(request).should =~ ["foo","bang"]
+ end
+
+ it "should return node names that match strict inequality constraints" do
+ Puppet::Node::Facts.new("foo", "uptime_days" => "30").save
+ Puppet::Node::Facts.new("bar", "uptime_days" => "60").save
+ Puppet::Node::Facts.new("baz", "uptime_days" => "90").save
+
+ request = Puppet::Indirector::Request.new(:facts, :search, nil,
+ {'facts.uptime_days.gt' => '20',
+ 'facts.uptime_days.lt' => '70'})
+
+ terminus.search(request).should =~ ["foo","bar"]
+ end
+
+ it "should return node names that match non-strict inequality constraints" do
+ Puppet::Node::Facts.new("foo", "uptime_days" => "30").save
+ Puppet::Node::Facts.new("bar", "uptime_days" => "60").save
+ Puppet::Node::Facts.new("baz", "uptime_days" => "90").save
+
+ request = Puppet::Indirector::Request.new(:facts, :search, nil,
+ {'facts.uptime_days.ge' => '30',
+ 'facts.uptime_days.le' => '60'})
+
+ terminus.search(request).should =~ ["foo","bar"]
+ end
+ end
end