def test_git_ref(url, unresolved_ref, resolved_ref):
    spec = '{}/{}'.format(
        quote(url, safe=''),
        quote(unresolved_ref)
    )

    provider = GitRepoProvider(spec=spec)
    slug = provider.get_build_slug()
    assert slug == url
    full_url = provider.get_repo_url()
    assert full_url == url
    ref = IOLoop().run_sync(provider.get_resolved_ref)
    if resolved_ref == True:
        # True means it should resolve, but don't check value
        assert ref is not None
        sha1_validate(ref)
    else:
        assert ref == resolved_ref
    if not resolved_ref:
        # we are done here if we don't expect to resolve
        return
    ref_url = IOLoop().run_sync(provider.get_resolved_ref_url)
    assert ref_url == full_url
    resolved_spec = IOLoop().run_sync(provider.get_resolved_spec)
    assert resolved_spec == quote(url, safe="") + f"/{ref}"
Exemplo n.º 2
0
def test_git_validate_url(url, unresolved_ref, expected):
    spec = "{}/{}".format(quote(url, safe=""), quote(unresolved_ref))

    if isinstance(expected, type) and issubclass(expected, Exception):
        with pytest.raises(expected):
            GitRepoProvider(spec=spec)
        return

    provider = GitRepoProvider(spec=spec)
    assert provider.repo == expected
Exemplo n.º 3
0
def test_git_ref(url, unresolved_ref, resolved_ref):
    spec = '{}/{}'.format(quote(url, safe=''), quote(unresolved_ref))

    provider = GitRepoProvider(spec=spec)
    slug = provider.get_build_slug()
    assert slug == url
    full_url = provider.get_repo_url()
    assert full_url == url
    ref = IOLoop().run_sync(provider.get_resolved_ref)
    assert ref == resolved_ref
Exemplo n.º 4
0
def test_git_ref():
    spec = '{}/{}'.format(
        quote('https://github.com/jupyterhub/zero-to-jupyterhub-k8s', safe=''),
        quote('f7f3ff6d1bf708bdc12e5f10e18b2a90a4795603'))

    provider = GitRepoProvider(spec=spec)
    slug = provider.get_build_slug()
    assert slug == 'https://github.com/jupyterhub/zero-to-jupyterhub-k8s'
    full_url = provider.get_repo_url()
    assert full_url == 'https://github.com/jupyterhub/zero-to-jupyterhub-k8s'
    ref = IOLoop().run_sync(provider.get_resolved_ref)
    assert ref == 'f7f3ff6d1bf708bdc12e5f10e18b2a90a4795603'