Sha256: fb8e41717497516d19a439c0754dd72e34bb65dd9d5c954a82003858d050604a

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

#!/usr/bin/env ruby
#
#  Created by Luke Kanies on 2006-11-12.
#  Copyright (c) 2006. All rights reserved.

$:.unshift("../../../lib") if __FILE__ =~ /\.rb$/

require 'puppettest'

if Puppet::Type.type(:host).provider(:netinfo).suitable?
class TestNetinfoHostProvider < Test::Unit::TestCase
	include PuppetTest
	
	def setup
	    super
	    @host = Puppet::Type.type(:host)
	    @provider = @host.provider(:netinfo)
    end

	def test_list
	    list = nil
	    assert_nothing_raised do
	        list = @provider.list
        end
        assert(list.length > 0)
        list.each do |obj|
            prov = obj.provider
            assert_instance_of(@host, obj)
            assert(prov.name, "objects do not have names")
            assert(prov.ip, "Did not get value for device in %s" % prov.ip)
        end

        assert(list.detect { |m| m.provider.name == "localhost"}, "Could not find localhost")
    end
    
    if Process.uid == 0
    def test_simple
        localhost = nil
        assert_nothing_raised do
            localhost = @host.create :name => "localhost", :check => [:ip], :provider => :netinfo
        end
        
        assert_nothing_raised do
            localhost.retrieve
        end
        
        prov = localhost.provider
        
        assert_nothing_raised do
            assert(prov.ip, "Did not find value for ip")
            assert(prov.ip != :absent, "Netinfo thinks the localhost is missing")
        end
    end
end
end
end

# $Id: netinfo.rb 2170 2007-02-07 17:21:52Z luke $

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-0.22.4 test/ral/providers/host/netinfo.rb