mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add unit tests for GECOS fields
This commit is contained in:
parent
ed940c4f58
commit
d5c9ca0fbc
1 changed files with 18 additions and 0 deletions
|
@ -393,3 +393,21 @@ class UserAddTestCase(TestCase, LoaderModuleMockMixin):
|
|||
mock = MagicMock(side_effect=[{'name': ''}, False, {'name': ''}])
|
||||
with patch.object(useradd, 'info', mock):
|
||||
self.assertFalse(useradd.rename('salt', 'salt'))
|
||||
|
||||
def test_build_gecos_field(self):
|
||||
'''
|
||||
Test if gecos fields are built correctly (removing trailing commas)
|
||||
'''
|
||||
test_gecos = {'fullname': 'Testing',
|
||||
'roomnumber': 1234,
|
||||
'workphone': 22222,
|
||||
'homephone': 99999}
|
||||
expected_gecos_fields = 'Testing,1234,22222,99999'
|
||||
self.assertEqual(useradd._build_gecos(test_gecos), expected_gecos_fields)
|
||||
test_gecos.pop('roomnumber')
|
||||
test_gecos.pop('workphone')
|
||||
expected_gecos_fields = 'Testing,,,99999'
|
||||
self.assertEqual(useradd._build_gecos(test_gecos), expected_gecos_fields)
|
||||
test_gecos.pop('homephone')
|
||||
expected_gecos_fields = 'Testing'
|
||||
self.assertEqual(useradd._build_gecos(test_gecos), expected_gecos_fields)
|
||||
|
|
Loading…
Add table
Reference in a new issue