diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 22:33:29 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 22:33:29 +0000 |
| commit | 3f15e38cb9e6cf69805b5608bda015a17c46db49 (patch) | |
| tree | 678e0fb9c4c8c3d1205f189c51e447519180d8fd /test | |
| parent | f420135270ab66c7bad10ebc4b031ddac3b57659 (diff) | |
Adding initial host support. I can promise that this will soon (hopefully almost immediately) be abstracted to make it easy to add new file types.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@817 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
| -rwxr-xr-x | test/types/host.rb | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/test/types/host.rb b/test/types/host.rb new file mode 100755 index 000000000..a3bd02788 --- /dev/null +++ b/test/types/host.rb @@ -0,0 +1,93 @@ +# Test host job creation, modification, and destruction + +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = "../../../../language/trunk" +end + +require 'puppettest' +require 'puppet' +require 'puppet/type/host' +require 'test/unit' +require 'facter' + +class TestCron < Test::Unit::TestCase + include TestPuppet + def setup + super + # god i'm lazy + @hosttype = Puppet.type(:host) + @oldhosttype = @hosttype.hosttype + end + + def teardown + @hosttype.hosttype = @oldhosttype + Puppet.type(:file).clear + super + end + + # Here we just create a fake host type that answers to all of the methods + # but does not modify our actual system. + def mkfaketype + @fakehosttype = Class.new { + attr_accessor :synced, :loaded, :path + @tabs = Hash.new("") + def clear + @text = nil + end + + def initialize(path) + @path = path + @text = nil + end + + def read + @loaded = Time.now + @text + end + + def write(text) + @syned = Time.now + @text = text + end + + def remove + @text = "" + end + } + + @hosttype.hosttype = @fakehosttype + end + + def test_simplehost + mkfaketype + host = nil + assert_nothing_raised { + assert_nil(Puppet.type(:host).retrieve) + } + + assert_nothing_raised { + host = Puppet.type(:host).create( + :name => "culain", + :ip => "192.168.0.3" + ) + } + + assert_nothing_raised { + Puppet.type(:host).store + } + + assert_nothing_raised { + assert_equal(Puppet.type(:host).fileobj.read, Puppet.type(:host).to_file) + } + end + + def test_hostsparse + assert_nothing_raised { + Puppet.type(:host).retrieve + } + end +end + +# $Id$ |
