From a9df49d3ee02ed11b82107ea035b9089ca7a2a56 Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 3 May 2006 04:36:02 +0000 Subject: Fixing some naming problems with crons, and adding appropriate tests git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1166 980ebf18-57e1-0310-9a29-db15c13687c0 --- test/types/cron.rb | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/types/cron.rb b/test/types/cron.rb index d96d06e0b..496274d88 100755 --- a/test/types/cron.rb +++ b/test/types/cron.rb @@ -253,17 +253,18 @@ class TestCron < Test::Unit::TestCase tab = @fakefiletype.new(@me) tab.remove - name = "storeandretrieve" - cron = mkcron(name) - comp = newcomp(name, cron) - trans = assert_events([:cron_created], comp, name) - - cron = nil + %w{storeandretrieve a-name another-name more_naming SomeName}.each do |name| + cron = mkcron(name) + comp = newcomp(name, cron) + trans = assert_events([:cron_created], comp, name) + + cron = nil - Puppet.type(:cron).retrieve(@me) + Puppet.type(:cron).retrieve(@me) - assert(cron = Puppet.type(:cron)[name], "Could not retrieve named cron") - assert_instance_of(Puppet.type(:cron), cron) + assert(cron = Puppet.type(:cron)[name], "Could not retrieve named cron") + assert_instance_of(Puppet.type(:cron), cron) + end end # Do input validation testing on all of the parameters. @@ -405,6 +406,22 @@ class TestCron < Test::Unit::TestCase @crontype.retrieve("nosuchuser") end end + + def test_names + cron = mkcron("nametest") + + ["bad name", "bad.name"].each do |name| + assert_raise(ArgumentError) do + cron[:name] = name + end + end + + ["good-name", "good-name", "AGoodName"].each do |name| + assert_nothing_raised do + cron[:name] = name + end + end + end end # $Id$ -- cgit