Skip to content

Commit

Permalink
[irods#7734] Add tests to ensure iadmin failures exit nonzero
Browse files Browse the repository at this point in the history
  • Loading branch information
FifthPotato authored and alanking committed Nov 20, 2024
1 parent 13c08da commit a6d646c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/irods/test/test_iadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,12 @@ def test_iadmin_mkgroup_returns_correct_error_on_duplicate_group__issue_7599(sel
finally:
self.admin.run_icommand(['iadmin', 'rmgroup', test_group_name])

def test_iadmin_exits_nonzero_on_nonexistent_command__issue_7734(self):
# Nonexistent command
ec, _, _ = self.admin.assert_icommand(['iadmin', 'nonexistentcommand'], 'STDERR');
self.assertNotEqual(ec, 0)


class Test_Iadmin_Resources(resource_suite.ResourceBase, unittest.TestCase):

def setUp(self):
Expand Down Expand Up @@ -2133,6 +2139,34 @@ def test_modrepl_as_rodsuser(self):
if os.path.exists(original_file_path):
os.unlink(original_file_path)

def test_iadmin_modrepl_exits_nonzero_on_failure__issue_7734(self):
# Bad parameters to modrepl
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'foo', 'bar', 'baz'], 'STDERR');
self.assertNotEqual(ec, 0)

# Nonexistent data object
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', '/tempZone/object/does/not/exist', 'replica_number', '0', 'DATA_COMMENTS', 'something'], 'STDERR');
self.assertNotEqual(ec, 0)

test_file_name = 'test_file_name_issue_7734'
self.admin.assert_icommand(['itouch', test_file_name])

# Nonexistent replica number
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', self.admin.session_collection + '/' + test_file_name, 'replica_number', '123', 'DATA_COMMENTS', 'something'], 'STDERR');
self.assertNotEqual(ec, 0)

# Invalid replica number
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'logical_path', self.admin.session_collection + '/' + test_file_name, 'replica_number', 'abc', 'DATA_COMMENTS', 'something'], 'STDERR');
self.assertNotEqual(ec, 0)

# Invalid data object ID
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'data_id', 'abc', 'replica_number', '123456789', 'DATA_COMMENTS', 'something'], 'STDERR');
self.assertNotEqual(ec, 0)

# Nonexistent data object ID
ec, _, _ = self.admin.assert_icommand(['iadmin', 'modrepl', 'data_id', '1234567', 'replica_number', '123456789', 'DATA_COMMENTS', 'something'], 'STDERR');
self.assertNotEqual(ec, 0)

class test_moduser_user(unittest.TestCase):
"""Test modifying a user."""
@classmethod
Expand Down

0 comments on commit a6d646c

Please sign in to comment.