Add test for deprecated legacy buildpack

Tests that the legacy buildpack raises exceptions when it is triggered.
pull/829/head
Tim Head 2020-01-25 07:35:00 +01:00
rodzic 1a1fd34391
commit 9cfdb9b5f4
4 zmienionych plików z 37 dodań i 29 usunięć

Wyświetl plik

@ -1,14 +0,0 @@
FROM andrewosh/binder-base
USER root
# Add Julia dependencies
RUN apt-get update
RUN apt-get install -y julia libnettle4 && apt-get clean
USER main
# Install Julia kernel
RUN julia -e 'Pkg.add("IJulia")'
ADD verify verify

Wyświetl plik

@ -1,8 +0,0 @@
Docker - Legacy Dockerfiles
---------------------------
This demonstrates the Dockerfile syntax that was often found in the first
version of Binder. It sources the ``andrewosh`` Docker image, which
contained many different dependencies, then installs Julia. We encourage
users to source one of the Jupyter base images as they are more streamlined,
reliable, and efficient.

Wyświetl plik

@ -1,7 +0,0 @@
#!/usr/bin/env python
import os
import sys
assert sys.version_info[:2] == (3, 5), sys.version
import jupyter

Wyświetl plik

@ -0,0 +1,37 @@
from os.path import join as pjoin
import pytest
from tempfile import TemporaryDirectory
from repo2docker.buildpacks import LegacyBinderDockerBuildPack
from repo2docker.utils import chdir
def test_legacy_raises():
# check legacy buildpack raises on a repo that triggers it
with TemporaryDirectory() as repodir:
with open(pjoin(repodir, "Dockerfile"), "w") as d:
d.write("FROM andrewosh/binder-base")
with chdir(repodir):
bp = LegacyBinderDockerBuildPack()
with pytest.raises(RuntimeError):
bp.detect()
def test_legacy_doesnt_detect():
# check legacy buildpack doesn't trigger
with TemporaryDirectory() as repodir:
with open(pjoin(repodir, "Dockerfile"), "w") as d:
d.write("FROM andrewosh/some-image")
with chdir(repodir):
bp = LegacyBinderDockerBuildPack()
assert not bp.detect()
def test_legacy_on_repo_without_dockerfile():
# check legacy buildpack doesn't trigger on a repo w/o Dockerfile
with TemporaryDirectory() as repodir:
with chdir(repodir):
bp = LegacyBinderDockerBuildPack()
assert not bp.detect()