summaryrefslogtreecommitdiffstats
path: root/spec/unit/node
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-11-03 20:00:46 -0700
committerJesse Wolfe <jes5199@gmail.com>2010-11-03 20:04:31 -0700
commit7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b (patch)
tree2ca24f5af952c5ef5456ec85ad4fe9e5acf14ac3 /spec/unit/node
parent9e2a0e41dfb253a19180aeea6b66f65ca8d63133 (diff)
parent4d3c41ee5316285bb0df38aeeb76746016803c16 (diff)
downloadpuppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.tar.gz
puppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.tar.xz
puppet-7236a33d6c5c9fbb0f46ffd7826965dbaae6a39b.zip
Merge branch 'next'
This marks the end of our first agile iteration.
Diffstat (limited to 'spec/unit/node')
-rwxr-xr-xspec/unit/node/facts_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/unit/node/facts_spec.rb b/spec/unit/node/facts_spec.rb
index 394db7913..cb2aa3dc7 100755
--- a/spec/unit/node/facts_spec.rb
+++ b/spec/unit/node/facts_spec.rb
@@ -109,5 +109,29 @@ describe Puppet::Node::Facts, "when indirecting" do
facts = Puppet::Node::Facts.new("me", "one" => "two", "three" => "four")
facts.values[:_timestamp].should be_instance_of(Time)
end
+
+ describe "using pson" do
+ before :each do
+ @timestamp = Time.parse("Thu Oct 28 11:16:31 -0700 2010")
+ @expiration = Time.parse("Thu Oct 28 11:21:31 -0700 2010")
+ end
+
+ it "should accept properly formatted pson" do
+ pson = %Q({"name": "foo", "expiration": "#{@expiration}", "timestamp": "#{@timestamp}", "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 == @expiration
+ facts.values.should == {'a' => '1', 'b' => '2', 'c' => '3', :_timestamp => @timestamp}
+ end
+
+ it "should generate properly formatted pson" do
+ Time.stubs(:now).returns(@timestamp)
+ facts = Puppet::Node::Facts.new("foo", {'a' => 1, 'b' => 2, 'c' => 3})
+ facts.expiration = @expiration
+ 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
+ end
end
end