From 9418066cc806ca172c1214fb112c09ac23e41acb Mon Sep 17 00:00:00 2001 From: Marc Fournier Date: Wed, 4 Jan 2012 12:21:05 +0100 Subject: couchdblookup: added case for map+reduce view. --- spec/unit/puppet/parser/functions/couchdblookup_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec/unit/puppet/parser/functions/couchdblookup_spec.rb') diff --git a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb b/spec/unit/puppet/parser/functions/couchdblookup_spec.rb index 4e9ab76..2af51a9 100755 --- a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb +++ b/spec/unit/puppet/parser/functions/couchdblookup_spec.rb @@ -54,4 +54,20 @@ describe "the couchdblookup function" do result.should raise_error(Puppet::ParseError) end + it "should return an array the values from a couchdb reduced view" do + sample_json = File.open(@datapath + 'map+reduce.txt') + OpenURI.stub!(:open_uri).and_return(sample_json) + + result = @scope.function_couchdblookup(["http://fake/uri", "value"]) + result.should eq(["foo", "bar", "baz"]) + end + + it "should raise a ParseError if a key can't be found in the rows of a couchdb reduced view" do + sample_json = File.open(@datapath + 'map+reduce.txt') + OpenURI.stub!(:open_uri).and_return(sample_json) + + result = lambda { @scope.function_couchdblookup(["http://fake/uri", "fake-key"]) } + result.should raise_error(Puppet::ParseError) + end + end -- cgit v1.2.3