############################################################################### # tc_unix.rb # # Test suite for the Unix version of sys-admin. This test should be run # via the 'rake test' task. ############################################################################### require 'test/unit' require 'sys/admin' include Sys class TC_Sys_Admin_Unix < Test::Unit::TestCase def setup @user = "nobody" @userid = 0 @group = "sys" @groupid = 3 end def test_version assert_equal('1.4.3', Admin::VERSION) end def test_get_login assert_respond_to(Admin, :get_login) assert_nothing_raised{ Admin.get_login } assert_kind_of(String, Admin.get_login) end def test_get_user assert_respond_to(Admin, :get_user) assert_nothing_raised{ Admin.get_user(@user) } assert_nothing_raised{ Admin.get_user(@userid) } assert_kind_of(User, Admin.get_user(@user)) assert_kind_of(User, Admin.get_user(@userid)) assert_raises(Admin::Error){ Admin.get_user("foofoo") } end def test_users assert_respond_to(Admin, :users) assert_nothing_raised{ Admin.users } assert_kind_of(Array, Admin.users) assert_kind_of(User, Admin.users.first) end def test_users_block_form array = [] assert_nothing_raised{ Admin.users{ |g| array << g } } assert_equal(true, Admin.users.length == array.length) assert_nothing_raised{ Admin.users{ |g| break } } end def test_get_group assert_respond_to(Admin, :get_group) assert_nothing_raised{ Admin.get_group(@group) } assert_nothing_raised{ Admin.get_group(@groupid) } assert_kind_of(Group, Admin.get_group(@group)) assert_kind_of(Group, Admin.get_group(@groupid)) assert_raises(Admin::Error){ Admin.get_group("foofoo") } end def test_groups assert_respond_to(Admin, :groups) assert_nothing_raised{ Admin.groups } assert_kind_of(Array, Admin.groups) assert_kind_of(Group, Admin.groups.first) end def test_groups_block_form array = [] assert_nothing_raised{ Admin.groups{ |g| array << g } } assert_equal(true, Admin.groups.length == array.length) assert_nothing_raised{ Admin.groups{ |g| break } } end def teardown @user = nil @userid = nil @group = nil @groupid = nil end end