summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarc Fournier <marc.fournier@camptocamp.com>2012-01-04 13:17:38 +0100
committerMarc Fournier <marc.fournier@camptocamp.com>2012-01-04 13:17:38 +0100
commitcb96d902a91325998765d9c981eab7ea0da098da (patch)
tree88ce258415400f938383bf6e01ea836df21b53aa /spec
parent9418066cc806ca172c1214fb112c09ac23e41acb (diff)
couchdblookup: 2 more tests
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/data/missing.txt1
-rw-r--r--spec/unit/data/proxy-failure.txt1
-rwxr-xr-xspec/unit/puppet/parser/functions/couchdblookup_spec.rb16
3 files changed, 18 insertions, 0 deletions
diff --git a/spec/unit/data/missing.txt b/spec/unit/data/missing.txt
new file mode 100644
index 0000000..4e6d97e
--- /dev/null
+++ b/spec/unit/data/missing.txt
@@ -0,0 +1 @@
+{"error":"not_found","reason":"missing"}
diff --git a/spec/unit/data/proxy-failure.txt b/spec/unit/data/proxy-failure.txt
new file mode 100644
index 0000000..f5f1c37
--- /dev/null
+++ b/spec/unit/data/proxy-failure.txt
@@ -0,0 +1 @@
+<html><body><h1>It works!</h1></body></html>
diff --git a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb b/spec/unit/puppet/parser/functions/couchdblookup_spec.rb
index 2af51a9..8777d71 100755
--- a/spec/unit/puppet/parser/functions/couchdblookup_spec.rb
+++ b/spec/unit/puppet/parser/functions/couchdblookup_spec.rb
@@ -70,4 +70,20 @@ describe "the couchdblookup function" do
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