Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
(puppetlabs/puppet) (#8235) Improve Hiera data_binding test coverage
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
wearetherob...@puppetlabs.com  
View profile  
 More options May 2 2012, 4:00 pm
From: wearetherob...@puppetlabs.com
Date: Wed, 02 May 2012 13:00:12 -0700
Local: Wed, May 2 2012 4:00 pm
Subject: (puppetlabs/puppet) (#8235) Improve Hiera data_binding test coverage

Please review pull request #732: (#8235) Improve Hiera data_binding test coverage opened by (kelseyhightower)

Description:

Add tests to exercise Hiera lookup for real, none of that stubbing stuff.
These test only run if Hiera is installed.

This patch does not introduce any changes in behavior.

  • Opened: Wed May 02 19:53:56 UTC 2012
  • Based on: puppetlabs:master (ba80b0e9fad27f2171b7f5e5db4253b89c70dc85)
  • Requested merge: kelseyhightower:maint/master/8235_improve_plugin_system_test_coverage (9a8d1b29c87fa9c28b99abbeb6ddd081d69c7f81)

Diff follows:

diff --git a/spec/fixtures/unit/indirector/hiera/global.yaml b/spec/fixtures/unit/indirector/hiera/global.yaml
new file mode 100644
index 0000000..0853e0e
--- /dev/null
+++ b/spec/fixtures/unit/indirector/hiera/global.yaml
@@ -0,0 +1,10 @@
+---
+integer: 3000
+string: 'apache'
+hash:
+  user:  'Hightower'
+  group: 'admin'
+  mode:  '0644'
+array:
+ - '0.ntp.puppetlabs.com'
+ - '1.ntp.puppetlabs.com'
diff --git a/spec/unit/indirector/hiera_spec.rb b/spec/unit/indirector/hiera_spec.rb
index 7cb0b0d..ce03c68 100644
--- a/spec/unit/indirector/hiera_spec.rb
+++ b/spec/unit/indirector/hiera_spec.rb
@@ -2,6 +2,8 @@
 require 'puppet/indirector/hiera'
 
 describe Puppet::Indirector::Hiera do
+  include PuppetSpec::Files
+
   before do
     Puppet.settings[:hiera_config] = {}
     Puppet::Indirector::Terminus.stubs(:register_terminus_class)
@@ -15,7 +17,23 @@ module Testing; end
 
   let(:model)   { mock('model') }
   let(:options) { {:host => 'foo' } }
-  let(:request) { stub('request', :key => "port", :options => options) }
+
+  let(:request_integer) do
+    stub('request', :key => "integer", :options => options)
+  end
+
+  let(:request_string) do
+    stub('request', :key => "string", :options => options)
+  end
+
+  let(:request_array) do
+    stub('request', :key => "array", :options => options)
+  end
+
+  let(:request_hash) do
+    stub('request', :key => "hash", :options => options)
+  end
+
   let(:indirection) do
     stub('indirection', :name => :none, :register_terminus_type => nil,
       :model => model)
@@ -36,13 +54,41 @@ module Testing; end
       "Hiera terminus not supported without hiera gem"
   end
 
-  describe "the behavior of the find method" do
-    it "should lookup the requested key in hiera", :if => Puppet.features.hiera? do
-      Hiera.any_instance.expects(:lookup).with("port", nil, facts, nil, nil).returns('3000')
-      Puppet::Node::Facts.indirection.expects(:find).with('foo').returns(facter_obj)
+  describe "the behavior of the find method", :if => Puppet.features.hiera? do
+    before do
+      Puppet.settings[:hiera_config] = {
+        :yaml      => { :datadir => datadir },
+        :hierarchy => ['global'],
+        :logger    => 'noop'
+      }
+      Puppet::Node::Facts.indirection.expects(:find).with('foo').
+        returns(facter_obj)
+    end
+
+    let(:datadir)     { my_fixture_dir }
+    let(:data_binder) { @hiera_class.new }
+
+    it "support looking up an integer" do
+      data_binder.find(request_integer).should == 3000
+    end
+
+    it "should support looking up a string" do
+      data_binder.find(request_string).should == 'apache'
+    end
+
+    it "should support looking up an array" do
+      data_binder.find(request_array).should == [
+        '0.ntp.puppetlabs.com',
+        '1.ntp.puppetlabs.com',
+      ]
+    end
 
-      data_binder = @hiera_class.new
-      data_binder.find(request).should == '3000'
+    it "should support looking up a hash" do
+      data_binder.find(request_hash).should == {
+        'user'  => 'Hightower',
+        'group' => 'admin',
+        'mode'  => '0644'
+      }
     end
   end
 end

    


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
wearetherob...@puppetlabs.com  
View profile  
 More options May 3 2012, 3:30 pm
From: wearetherob...@puppetlabs.com
Date: Thu, 03 May 2012 12:30:20 -0700
Local: Thurs, May 3 2012 3:30 pm
Subject: (puppetlabs/puppet) (#8235) Improve Hiera data_binding test coverage

On Thu May 03 19:29:32 UTC 2012 pull request #732 was closed.

(#8235) Improve Hiera data_binding test coverage requested by (kelseyhightower)

The pull request was merged by: daniel-pittman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »