kopia lustrzana https://github.com/jupyterhub/repo2docker
Add tests for Git content provider
rodzic
e5c7fdd341
commit
02b41948dd
|
@ -51,7 +51,7 @@ env:
|
|||
- REPO_TYPE=r
|
||||
- REPO_TYPE=dockerfile
|
||||
- REPO_TYPE=external/*
|
||||
- REPO_TYPE=*.py
|
||||
- REPO_TYPE=**/*.py
|
||||
global:
|
||||
- secure: gX7IOkbjlvcDwIH24sOLhutINx6TZRwujEusMWh1dqgYG2D69qQai/mTrRXO9PGRrsvQwIBk4RcILKAiZnk5O2Z1hLoIHk/oU2mNUmE44dDm4Xf/VTTdeYhjeOTR9B+KJ9NVwPxuSEDSND3lD7yFfvCqNXykipEhBtTliLupjWVxxXnaz0aZTYHUPJwanxdUc06AphSPwZjtm1m3qMUU8v7UdTGGAdW3NlgkKw0Xx2x5W31fW676vskC/GNQAbcRociYipuhSFWV4lu+6d8XF2xVO97xtzf54tBQzt6RgVfAKtiqkEIYSzJQBBpkQ6SM6yg+fQoQpOo8jPU9ZBjvaoopUG9vn8HRS/OtQrDcG3kEFnFAnaes8Iqtidp1deTn27LIlfCTl7kTFOp8yaaNlIMHJTJKTEMRhfdDlBYx7qiH8e9d/z37lupzY2loLHeNHdMRS1uYsfacZsmrnu9vAdpQmP1LuHivBPZEvgerinADaJiekelWOIEn956pDrno/YgnzP0i9LEBYnbbunqT8oEzLintNt5CXGdhkiG60j38McKCIn4sD6jbMMwgsqVFdClCBersyorKhOs7P8at5vX4xf8fMiKPC8LZPzYVIQYzCjmwSOFQ+Rzmz5gSj+DRTANKfHpzZCKZEF6amBYMGE1O5osF8m6M10vtW9ToK+s=
|
||||
- secure: Cfhb0BUT54JjEZD8n44Jj+o1lt5p32Lfg7W/euTyZ61YylDx0+XEYTzfWcwxOzH9fLpWr6dDrBMGHA/FPqsWA5BkoGdiBJ1OOVy2tmDRButctobWM3SVwa+Rhh8bZWlK8yKT2S3n6CtK4mesmjzdbUShL7YnKOSl8LBaTT5Y5oT8Oxsq51pfg8fJUImim8H20t8H7emaEzZorF4OSGRtajcAgukt5YoAqTEVDq+bFRBHZalxkcRqLhsGe3CCWa28kjGTL4MPZpCI6/AXIXHzihfG3rGq40ZT8jZ9GPP3MBgkiJWtFiTC9h16G34b/JI/TD40zCmoW9/9oVjRK4UlLGCAv6bgzFhCRof2abhB9NTZDniNzkO0T15uHs3VLbLCPYB0xYyClAFxm2P6e8WPChyENKfTNh+803IKFFo4JaTjOnKzi89N72v5+bT6ghP932nmjJr1AO65xjw63CeDmaLoHDY73n11DibybWQgEeiNzJuSzbIHyqMPhW5XqeroEjKKstdPHtVfOViI9ywjEMy0HCPsspaVI7Aow0Iv8E4Ajvd32W7z0h0fSCx/i25hEOAo2vhBsmQKJA7IquB3N88M11L874h/8J+oc/osW1EB5z7Ukke5YCq94Qh3qImSIhJULXMMc1QjEqYsqhLXtiMG2HUge0Y5hwwnnbEIRMQ=
|
||||
|
|
|
@ -3,7 +3,7 @@ import shutil
|
|||
import os
|
||||
import subprocess
|
||||
from tempfile import TemporaryDirectory
|
||||
from repo2docker.contentproviders.git import GitContentProvider
|
||||
from repo2docker.contentproviders.git import Git
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
@ -16,23 +16,31 @@ def git_repo():
|
|||
|
||||
with TemporaryDirectory() as gitdir:
|
||||
subprocess.check_call(['git', 'init'], cwd=gitdir)
|
||||
|
||||
yield gitdir
|
||||
|
||||
|
||||
def test_clone():
|
||||
"""Test simple git clone to a target dir
|
||||
"""
|
||||
"""Test simple git clone to a target dir"""
|
||||
with git_repo() as upstream:
|
||||
with open(os.path.join(upstream, 'test'), 'w') as f:
|
||||
f.write("Hello")
|
||||
|
||||
subprocess.check_call(['git', 'add', 'test'], cwd=upstream)
|
||||
subprocess.check_call(['git', 'commit', '-m', 'Test commit'], cwd=upstream)
|
||||
subprocess.check_call(['git', 'commit', '-m', 'Test commit'],
|
||||
cwd=upstream)
|
||||
|
||||
with TemporaryDirectory() as clone_dir:
|
||||
spec = {
|
||||
'url': upstream
|
||||
}
|
||||
for _ in GitContentProvider().provide(spec, clone_dir, False):
|
||||
spec = {'repo': upstream}
|
||||
for _ in Git().fetch(spec, clone_dir):
|
||||
pass
|
||||
assert os.path.exists(os.path.join(clone_dir, 'test'))
|
||||
|
||||
|
||||
def test_always_accept():
|
||||
# The git content provider should always accept a spec
|
||||
assert Git().detect('/tmp/doesnt-exist', ref='1234')
|
||||
assert Git().detect('/tmp/doesnt-exist')
|
||||
# a path that exists
|
||||
assert Git().detect('/etc', ref='1234')
|
||||
# a remote URL
|
||||
assert Git().detect('https://example.com/path/here')
|
||||
|
|
Ładowanie…
Reference in New Issue