Add test for deprecated legacy buildpack
Tests that the legacy buildpack raises exceptions when it is triggered.
DELETE
tests/dockerfile/legacy/Dockerfile
-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

DELETE
tests/dockerfile/legacy/README.rst
-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.

DELETE
tests/dockerfile/legacy/verify
-#!/usr/bin/env python
-import os
-import sys
-
-assert sys.version_info[:2] == (3, 5), sys.version
-
-import jupyter

ADD
tests/unit/test_buildpack.py
+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()

Add test for deprecated legacy buildpack

Tests that the legacy buildpack raises exceptions when it is triggered.