summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/facts_spec.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index a130ae3f8..3c7c9d08b 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -110,7 +110,11 @@ describe Puppet::Node::Facts, "when indirecting" do
end
it "should accept properly formatted pson" do
- pson = %Q({"name": "foo", "expiration": "#{@expiration}", "timestamp": "#{@timestamp}", "values": {"a": "1", "b": "2", "c": "3"}})
+ facts = Puppet::Node::Facts.new("foo")
+ facts.values = {"a" => "1", "b" => "2", "c" => "3"}
+ facts.expiration = Time.now
+ #pson = %Q({"document_type": "Puppet::Node::Facts", "data: {"name": "foo", "expiration": "#{@expiration}", "timestamp": "#{@timestamp}", "values": {"a": "1", "b": "2", "c": "3"}}})
+ pson = %Q({"data": {"name":"foo", "expiration":"#{@expiration}", "timestamp": "#{@timestamp}", "values":{"a":"1","b":"2","c":"3"}}, "document_type":"Puppet::Node::Facts"})
format = Puppet::Network::FormatHandler.format('pson')
facts = format.intern(Puppet::Node::Facts,pson)
facts.name.should == 'foo'
@@ -125,6 +129,20 @@ describe Puppet::Node::Facts, "when indirecting" do
pson = PSON.parse(facts.to_pson)
pson.should == {"name"=>"foo", "timestamp"=>@timestamp.to_s, "expiration"=>@expiration.to_s, "values"=>{"a"=>1, "b"=>2, "c"=>3}}
end
+
+ it "should not include nil values" do
+ facts = Puppet::Node::Facts.new("foo", {'a' => 1, 'b' => 2, 'c' => 3})
+ pson = PSON.parse(facts.to_pson)
+ pson.should_not be_include("expiration")
+ end
+
+ it "should be able to handle nil values" do
+ pson = %Q({"name": "foo", "values": {"a": "1", "b": "2", "c": "3"}})
+ format = Puppet::Network::FormatHandler.format('pson')
+ facts = format.intern(Puppet::Node::Facts,pson)
+ facts.name.should == 'foo'
+ facts.expiration.should be_nil
+ end
end
end
end