summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-15 21:04:14 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-02-15 21:04:14 +0000
commit6fe01cedeb2fe00df62bf63d7f7375d18d0663ca (patch)
treea138de582c15714b724851c3ffc0fce5448fbedd /test
parent8602932432c62630ec47a672fb79d6aa90dcbfc7 (diff)
downloadpuppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.tar.gz
puppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.tar.xz
puppet-6fe01cedeb2fe00df62bf63d7f7375d18d0663ca.zip
Tracked down a few other bugs; everything now passes on debian in preparation for 0.13.2
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@914 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/other/log.rb7
-rwxr-xr-xtest/puppet/utiltest.rb100
-rwxr-xr-xtest/types/group.rb16
3 files changed, 121 insertions, 2 deletions
diff --git a/test/other/log.rb b/test/other/log.rb
index ad13b15bf..a138b198b 100644
--- a/test/other/log.rb
+++ b/test/other/log.rb
@@ -14,9 +14,15 @@ require 'test/unit'
class TestLog < Test::Unit::TestCase
include TestPuppet
+ def setup
+ super
+ @oldloglevel = Puppet::Log.level
+ end
+
def teardown
super
Puppet::Log.close
+ Puppet::Log.level = @oldloglevel
end
def getlevels
@@ -44,6 +50,7 @@ class TestLog < Test::Unit::TestCase
def test_logfile
fact = nil
levels = nil
+ oldlevel = Puppet::Log.level
Puppet::Log.level = :debug
levels = getlevels
logfile = tempfile()
diff --git a/test/puppet/utiltest.rb b/test/puppet/utiltest.rb
index 5ca2e4343..ec398d8b9 100755
--- a/test/puppet/utiltest.rb
+++ b/test/puppet/utiltest.rb
@@ -43,6 +43,106 @@ class TestPuppetUtil < Test::Unit::TestCase
threads.each { |th| th.join }
end
+ # First verify we can convert a known user
+ def test_gidbyname
+ %x{groups}.split(" ").each { |group|
+ gid = nil
+ assert_nothing_raised {
+ gid = Puppet::Util.gid(group)
+ }
+
+ assert(gid, "Could not retrieve gid for %s" % group)
+
+ assert(Puppet.type(:group)[group], "Util did not create %s" % group)
+ }
+ end
+
+ # Then verify we can retrieve a known group by gid
+ def test_gidbyid
+ %x{groups}.split(" ").each { |group|
+ obj = Puppet.type(:group).create(
+ :name => group,
+ :check => [:gid]
+ )
+ obj.retrieve
+ id = obj.is(:gid)
+ gid = nil
+ assert_nothing_raised {
+ gid = Puppet::Util.gid(id)
+ }
+
+ assert(gid, "Could not retrieve gid for %s" % group)
+ assert_equal(id, gid, "Got mismatched ids")
+ }
+ end
+
+ # Finally, verify that we can find groups by id even if we don't
+ # know them
+ def test_gidbyunknownid
+ gid = nil
+ group = Process.gid
+ assert_nothing_raised {
+ gid = Puppet::Util.gid(group)
+ }
+
+ assert(gid, "Could not retrieve gid for %s" % group)
+ assert_equal(group, gid, "Got mismatched ids")
+ end
+
+ def user
+ require 'etc'
+ unless defined? @user
+ obj = Etc.getpwuid(Process.uid)
+ @user = obj.name
+ end
+ return @user
+ end
+
+ # And do it all over again for users
+ # First verify we can convert a known user
+ def test_uidbyname
+ user = user()
+ uid = nil
+ assert_nothing_raised {
+ uid = Puppet::Util.uid(user)
+ }
+
+ assert(uid, "Could not retrieve uid for %s" % user)
+ assert_equal(Process.uid, uid, "UIDs did not match")
+ assert(Puppet.type(:user)[user], "Util did not create %s" % user)
+ end
+
+ # Then verify we can retrieve a known user by uid
+ def test_uidbyid
+ user = user()
+ obj = Puppet.type(:user).create(
+ :name => user,
+ :check => [:uid]
+ )
+ obj.retrieve
+ id = obj.is(:uid)
+ uid = nil
+ assert_nothing_raised {
+ uid = Puppet::Util.uid(id)
+ }
+
+ assert(uid, "Could not retrieve uid for %s" % user)
+ assert_equal(id, uid, "Got mismatched ids")
+ end
+
+ # Finally, verify that we can find users by id even if we don't
+ # know them
+ def test_uidbyunknownid
+ uid = nil
+ user = Process.uid
+ assert_nothing_raised {
+ uid = Puppet::Util.uid(user)
+ }
+
+ assert(uid, "Could not retrieve uid for %s" % user)
+ assert_equal(user, uid, "Got mismatched ids")
+ end
+
unless Process.uid == 0
$stderr.puts "Run as root to perform Utility tests"
def test_nothing
diff --git a/test/types/group.rb b/test/types/group.rb
index 6f60de3e3..e1b4e4fed 100755
--- a/test/types/group.rb
+++ b/test/types/group.rb
@@ -214,6 +214,18 @@ class TestGroup < Test::Unit::TestCase
assert_equal(Process.gid, user.is(:gid), "Retrieved UID does not match")
end
+ def test_ensurevals
+ gobj = nil
+ assert_nothing_raised {
+ gobj = Puppet.type(:group).create(
+ :name => name,
+ :ensure => :exists
+ )
+ }
+
+ assert_equal(false, gobj.state(:ensure))
+ end
+
if Process.uid == 0
def test_mkgroup
gobj = nil
@@ -234,10 +246,10 @@ class TestGroup < Test::Unit::TestCase
#}
#end
assert(missing?(name), "Group %s is still present" % name)
-
assert_nothing_raised {
gobj = Puppet.type(:group).create(
- :name => name
+ :name => name,
+ :ensure => :present
)
comp = newcomp("groupmaker %s" % name, gobj)