summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 18:26:14 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 18:26:14 +0000
commitbbf2c547dc550c4423c94ceb53395d1146a46918 (patch)
tree37c5be69ee29153c1243323937c42e1f3e4b58cf /test
parent0c1714945692330ca76a6c254303ff4fcd466efb (diff)
Adding /etc/services support
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@821 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/types/host.rb31
-rwxr-xr-xtest/types/port.rb76
2 files changed, 78 insertions, 29 deletions
diff --git a/test/types/host.rb b/test/types/host.rb
index 84ff041a4..a1fedcd07 100755
--- a/test/types/host.rb
+++ b/test/types/host.rb
@@ -11,7 +11,7 @@ require 'puppet'
require 'test/unit'
require 'facter'
-class TestCron < Test::Unit::TestCase
+class TestHost < Test::Unit::TestCase
include TestPuppet
def setup
super
@@ -29,34 +29,7 @@ class TestCron < Test::Unit::TestCase
# 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.filetype = @fakehosttype
+ @hosttype.filetype = Puppet::FileType.filetype(:ram)
end
def test_simplehost
diff --git a/test/types/port.rb b/test/types/port.rb
new file mode 100755
index 000000000..5225f27ce
--- /dev/null
+++ b/test/types/port.rb
@@ -0,0 +1,76 @@
+# Test host job creation, modification, and destruction
+
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = "../../../../language/trunk"
+end
+
+require 'puppettest'
+require 'puppet'
+require 'puppet/type/parsedtype/port'
+require 'test/unit'
+require 'facter'
+
+class TestPort < Test::Unit::TestCase
+ include TestPuppet
+ def setup
+ super
+ @porttype = Puppet.type(:port)
+ @oldfiletype = @porttype.filetype
+ end
+
+ def teardown
+ @porttype.filetype = @oldfiletype
+ 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
+ @porttype.filetype = Puppet::FileType.filetype(:ram)
+ end
+
+ def test_simplehost
+ mkfaketype
+ host = nil
+ assert_nothing_raised {
+ assert_nil(Puppet.type(:port).retrieve)
+ }
+
+ assert_nothing_raised {
+ host = Puppet.type(:port).create(
+ :name => "puppet",
+ :number => 8139,
+ :protocols => "tcp",
+ :description => "The port that Puppet runs on"
+ )
+ }
+
+ assert_nothing_raised {
+ Puppet.type(:port).store
+ }
+
+ assert_nothing_raised {
+ assert_equal(Puppet.type(:port).fileobj.read, Puppet.type(:port).to_file)
+ }
+ end
+
+ def test_hostsparse
+ assert_nothing_raised {
+ Puppet.type(:port).retrieve
+ }
+
+ # Now just make we've got some ports we know will be there
+ dns = @porttype["domain"]
+ assert(dns, "Could not retrieve DNS port")
+
+ assert_equal("53", dns.is(:number), "DNS number was wrong")
+ %w{udp tcp}.each { |v|
+ assert(dns.is(:protocols).include?(v), "DNS did not include proto %s" % v)
+ }
+ end
+end
+
+# $Id$