From 2ac3b7c2e3283e5b0f48e6dd3d76c0192ee96a44 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 24 Nov 2015 17:15:12 +0100 Subject: test if couchrest gets installed with the correct version the old unit tests were not working anymore --- .../puppet/parser/functions/couchdblookup_spec.rb | 89 ---------------------- 1 file changed, 89 deletions(-) delete mode 100755 spec/unit/puppet/parser/functions/couchdblookup_spec.rb (limited to 'spec/unit/puppet/parser/functions') diff --git a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb b/spec/unit/puppet/parser/functions/couchdblookup_spec.rb deleted file mode 100755 index 8777d71..0000000 --- a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env rspec - -require 'puppet' - -describe "the couchdblookup function" do - before :all do - Puppet::Parser::Functions.autoloader.loadall - @datapath = File.dirname(__FILE__) + '/../../../data/' - end - - before :each do - @scope = Puppet::Parser::Scope.new - end - - it "should exist" do - Puppet::Parser::Functions.function("couchdblookup").should == "function_couchdblookup" - end - - it "should raise a ParseError unless there is exactly 2 arguments" do - lambda { @scope.function_couchdblookup([]) }.should raise_error(Puppet::ParseError) - lambda { @scope.function_couchdblookup([1]) }.should raise_error(Puppet::ParseError) - lambda { @scope.function_couchdblookup([1,2,3]) }.should raise_error(Puppet::ParseError) - end - - it "should return the value of a key from a single couchdb document" do - sample_json = File.open(@datapath + 'one-document.txt') - OpenURI.stub!(:open_uri).and_return(sample_json) - - result = @scope.function_couchdblookup(["http://fake/uri", "wiki"]) - result.should eq(true) - end - - it "should raise a ParseError if a key can't be found in a couchdb document" do - sample_json = File.open(@datapath + 'one-document.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 - - it "should return an array from the values of a couchdb view" do - sample_json = File.open(@datapath + 'map.txt') - OpenURI.stub!(:open_uri).and_return(sample_json) - - result = @scope.function_couchdblookup(["http://fake/uri", "value"]) - result.should eq(["foo", "bar"]) - end - - it "should raise a ParseError if a key can't be found in the rows of a couchdb view" do - sample_json = File.open(@datapath + 'map.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 - - 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 - - it "should raise a ParseError if couchdb can't find the requested document" do - sample_json = File.open(@datapath + 'missing.txt') - OpenURI.stub!(:open_uri).and_return(sample_json) - - result = lambda { @scope.function_couchdblookup(["http://fake/uri", "a-key"]) } - result.should raise_error(Puppet::ParseError) - end - - it "should raise a ParseError if input in not valid JSON" do - sample_json = File.open(@datapath + 'proxy-failure.txt') - OpenURI.stub!(:open_uri).and_return(sample_json) - - result = lambda { @scope.function_couchdblookup(["http://fake/uri", "a-key"]) } - result.should raise_error(Puppet::ParseError) - end - -end -- cgit v1.2.3