File: facts.rb

package info (click to toggle)
puppet 0.24.5-3%2Blenny2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 9,688 kB
  • ctags: 7,630
  • sloc: ruby: 97,655; sh: 721; lisp: 262; makefile: 167; xml: 122; python: 28
file content (44 lines) | stat: -rwxr-xr-x 1,451 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../spec_helper'

require 'puppet/node/facts'

describe Puppet::Node::Facts, " when indirecting" do
    before do
        @indirection = stub 'indirection', :request => mock('request'), :name => :facts

        # We have to clear the cache so that the facts ask for our indirection stub,
        # instead of anything that might be cached.
        Puppet::Indirector::Indirection.clear_cache
        @facts = Puppet::Node::Facts.new("me", "one" => "two")
    end

    it "should redirect to the specified fact store for retrieval" do
        Puppet::Node::Facts.stubs(:indirection).returns(@indirection)
        @indirection.expects(:find)
        Puppet::Node::Facts.find(:my_facts)
    end

    it "should redirect to the specified fact store for storage" do
        Puppet::Node::Facts.stubs(:indirection).returns(@indirection)
        @indirection.expects(:save)
        @facts.save
    end

    it "should default to the 'facter' terminus" do
        Puppet::Node::Facts.indirection.terminus_class.should == :facter
    end

    after do
        mocha_verify
        Puppet::Indirector::Indirection.clear_cache
    end
end

describe Puppet::Node::Facts, " when storing and retrieving" do
    it "should add metadata to the facts" do
        facts = Puppet::Node::Facts.new("me", "one" => "two", "three" => "four")
        facts.values[:_timestamp].should be_instance_of(Time)
    end
end