summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 20:09:39 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-13 20:09:39 +0000
commitc8b64014f1018dd437d1a0bd17db96b312e8af8a (patch)
tree6ac8c98afe4005b7606be06ab5d688859a3731a4 /test
parentbbf2c547dc550c4423c94ceb53395d1146a46918 (diff)
downloadpuppet-c8b64014f1018dd437d1a0bd17db96b312e8af8a.tar.gz
puppet-c8b64014f1018dd437d1a0bd17db96b312e8af8a.tar.xz
puppet-c8b64014f1018dd437d1a0bd17db96b312e8af8a.zip
Fixing up the parsedtypes, fixing Type.eachtype to ignore structure types
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@822 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rwxr-xr-xtest/types/host.rb43
-rwxr-xr-xtest/types/port.rb55
-rw-r--r--test/types/type.rb5
3 files changed, 99 insertions, 4 deletions
diff --git a/test/types/host.rb b/test/types/host.rb
index a1fedcd07..4c3c6d142 100755
--- a/test/types/host.rb
+++ b/test/types/host.rb
@@ -32,6 +32,19 @@ class TestHost < Test::Unit::TestCase
@hosttype.filetype = Puppet::FileType.filetype(:ram)
end
+ def mkhost
+ host = nil
+ assert_nothing_raised {
+ host = Puppet.type(:host).create(
+ :name => "culain",
+ :ip => "192.168.0.3",
+ :aliases => "puppet"
+ )
+ }
+
+ return host
+ end
+
def test_simplehost
mkfaketype
host = nil
@@ -51,7 +64,12 @@ class TestHost < Test::Unit::TestCase
}
assert_nothing_raised {
- assert_equal(Puppet.type(:host).fileobj.read, Puppet.type(:host).to_file)
+ assert(
+ Puppet.type(:host).to_file.include?(
+ Puppet.type(:host).fileobj.read
+ ),
+ "File does not include all of our objects"
+ )
}
end
@@ -60,6 +78,29 @@ class TestHost < Test::Unit::TestCase
Puppet.type(:host).retrieve
}
end
+
+ def test_moddinghost
+ mkfaketype
+ host = mkhost()
+
+ assert_events([:host_created], host)
+
+ host.retrieve
+
+ # This was a hard bug to track down.
+ assert_instance_of(String, host.is(:ip))
+
+ host[:aliases] = %w{madstop kirby yayness}
+
+ assert_events([:host_changed], host)
+ end
+
+ def test_multivalues
+ host = mkhost
+ assert_raise(Puppet::Error) {
+ host[:aliases] = "puppetmasterd yayness"
+ }
+ end
end
# $Id$
diff --git a/test/types/port.rb b/test/types/port.rb
index 5225f27ce..74a445a94 100755
--- a/test/types/port.rb
+++ b/test/types/port.rb
@@ -32,6 +32,21 @@ class TestPort < Test::Unit::TestCase
@porttype.filetype = Puppet::FileType.filetype(:ram)
end
+ def mkport
+ port = nil
+ assert_nothing_raised {
+ port = Puppet.type(:port).create(
+ :name => "puppet",
+ :number => 8139,
+ :protocols => "tcp",
+ :description => "The port that Puppet runs on",
+ :aliases => "coolness"
+ )
+ }
+
+ return port
+ end
+
def test_simplehost
mkfaketype
host = nil
@@ -40,7 +55,7 @@ class TestPort < Test::Unit::TestCase
}
assert_nothing_raised {
- host = Puppet.type(:port).create(
+ port = Puppet.type(:port).create(
:name => "puppet",
:number => 8139,
:protocols => "tcp",
@@ -53,11 +68,16 @@ class TestPort < Test::Unit::TestCase
}
assert_nothing_raised {
- assert_equal(Puppet.type(:port).fileobj.read, Puppet.type(:port).to_file)
+ assert(
+ Puppet.type(:port).to_file.include?(
+ Puppet.type(:port).fileobj.read
+ ),
+ "File does not include all of our objects"
+ )
}
end
- def test_hostsparse
+ def test_portsparse
assert_nothing_raised {
Puppet.type(:port).retrieve
}
@@ -71,6 +91,35 @@ class TestPort < Test::Unit::TestCase
assert(dns.is(:protocols).include?(v), "DNS did not include proto %s" % v)
}
end
+
+ def test_moddingport
+ mkfaketype
+ port = nil
+ assert_nothing_raised {
+ port = Puppet.type(:port).create(
+ :name => "puppet",
+ :number => 8139,
+ :protocols => "tcp",
+ :description => "The port that Puppet runs on"
+ )
+ }
+
+ assert_events([:port_created], port)
+
+ port[:protocols] = %w{tcp udp}
+
+ assert_events([:port_changed], port)
+ end
+
+ def test_multivalues
+ port = mkport
+ assert_raise(Puppet::Error) {
+ port[:protocols] = "udp tcp"
+ }
+ assert_raise(Puppet::Error) {
+ port[:aliases] = "puppetmasterd yayness"
+ }
+ end
end
# $Id$
diff --git a/test/types/type.rb b/test/types/type.rb
index fd551c4fd..5426ec669 100644
--- a/test/types/type.rb
+++ b/test/types/type.rb
@@ -30,6 +30,11 @@ class TestType < Test::Unit::TestCase
"Failed to retrieve %s by name" % name
)
+ # Skip types with no parameters or valid states
+ #unless ! type.parameters.empty? or ! type.validstates.empty?
+ # next
+ #end
+
assert(
type.namevar,
"Failed to retrieve namevar for %s" % name