Add tests for user options

pull/172/head
yuvipanda 2017-12-19 13:00:55 -08:00
rodzic 66ad81d42b
commit e9e6547384
1 zmienionych plików z 32 dodań i 0 usunięć

32
tests/users.py 100644
Wyświetl plik

@ -0,0 +1,32 @@
"""
Test that User name and ID mapping works
"""
import os
import subprocess
import tempfile
import time
def test_user():
"""
Validate user id and name setting
"""
ts = str(time.time())
with tempfile.TemporaryDirectory() as tmpdir:
username = os.getlogin()
subprocess.check_call([
'repo2docker',
'-v', '{}:/home/{}'.format(tmpdir, username),
'--user-id', '1000',
'--user-name', 'yuvipanda',
tmpdir,
'--',
'/bin/bash',
'-c', 'id -u > id && pwd > pwd && whoami > name'.format(ts)
])
with open(os.path.join(tmpdir, 'id')) as f:
assert f.read().strip() == '1000'
with open(os.path.join(tmpdir, 'pwd')) as f:
assert f.read().strip() == '/home/yuvipanda'
with open(os.path.join(tmpdir, 'name')) as f:
assert f.read().strip() == 'yuvipanda'