[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Paul Berry paul at puppetlabs.com
Tue May 10 07:59:47 UTC 2011


The following commit has been merged in the experimental branch:
commit 1f80cc6ed0caadd82171b4fb9fbe117142cd535e
Author: Paul Berry <paul at puppetlabs.com>
Date:   Mon Nov 1 13:32:14 2010 -0700

    Refactored Puppet::Node::Inventory::Yaml tests in preparation for adding freshness check

diff --git a/spec/unit/indirector/inventory/yaml_spec.rb b/spec/unit/indirector/inventory/yaml_spec.rb
index 3a7035a..a595f8a 100644
--- a/spec/unit/indirector/inventory/yaml_spec.rb
+++ b/spec/unit/indirector/inventory/yaml_spec.rb
@@ -7,7 +7,7 @@ require 'puppet/indirector/inventory/yaml'
 require 'puppet/indirector/request'
 
 describe Puppet::Node::Inventory::Yaml do
-  def setup_search_matching(matching, nonmatching, query)
+  def assert_search_matches(matching, nonmatching, query)
     request = Puppet::Indirector::Request.new(:inventory, :search, nil, query)
 
     Dir.stubs(:glob).returns(matching.keys + nonmatching.keys)
@@ -16,11 +16,11 @@ describe Puppet::Node::Inventory::Yaml do
         YAML.stubs(:load_file).with(key).returns value
       end
     end
-    return matching, request
+    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return node names that match the search query options" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386", 'processor_count' => '4'),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "i386", 'processor_count' => '4', 'randomfact' => 'foo')
       },
@@ -32,11 +32,10 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.architecture' => 'i386', 'facts.processor_count' => '4'}
     )
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return empty array when no nodes match the search query options" do
-    matching, request = setup_search_matching({}, {
+    assert_search_matches({}, {
         "/path/to/nonmatching.yaml"  => Puppet::Node::Facts.new("nonmatchingnode",  "architecture" => "powerpc", 'processor_count' => '10'),
         "/path/to/nonmatching1.yaml" => Puppet::Node::Facts.new("nonmatchingnode1", "architecture" => "powerpc", 'processor_count' => '5'),
         "/path/to/nonmatching2.yaml" => Puppet::Node::Facts.new("nonmatchingnode2", "architecture" => "i386",    'processor_count' => '5'),
@@ -44,12 +43,11 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.processor_count.lt' => '4', 'facts.processor_count.gt' => '4'}
     )
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
 
   it "should return node names that match the search query options with the greater than operator" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '10', 'randomfact' => 'foo')
       },
@@ -60,12 +58,10 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.processor_count.gt' => '4'}
     )
-
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return node names that match the search query options with the less than operator" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '30', 'randomfact' => 'foo')
       },
@@ -76,12 +72,10 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.processor_count.lt' => '50'}
     )
-
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return node names that match the search query options with the less than or equal to operator" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '5'),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
       },
@@ -92,12 +86,10 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.processor_count.le' => '50'}
     )
-
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return node names that match the search query options with the greater than or equal to operator" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => "i386",    'processor_count' => '100'),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => "powerpc", 'processor_count' => '50', 'randomfact' => 'foo')
       },
@@ -108,12 +100,10 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.processor_count.ge' => '50'}
     )
-
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 
   it "should return node names that match the search query options with the not equal operator" do
-    matching, request = setup_search_matching({
+    assert_search_matches({
         '/path/to/matching.yaml'  => Puppet::Node::Facts.new("matchingnode",  "architecture" => 'arm'                           ),
         '/path/to/matching1.yaml' => Puppet::Node::Facts.new("matchingnode1", "architecture" => 'powerpc', 'randomfact' => 'foo')
       },
@@ -124,7 +114,5 @@ describe Puppet::Node::Inventory::Yaml do
       },
       {'facts.architecture.ne' => 'i386'}
     )
-
-    Puppet::Node::Inventory::Yaml.new.search(request).should =~ matching.values.map {|facts| facts.name}
   end
 end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list