def test_copies_target_dir(self, tmpdir): tmpdir.ensure('foo', 'bar', 'Dockerfile') ps = PathSource('path', 'file://' + os.path.join(str(tmpdir), 'foo')) path = ps.path assert os.path.isfile(os.path.join(path, 'bar', 'Dockerfile')) # make sure these are the same even on second access to ps.path/ps.get(), # since second (and any subsequent) access does a bit different thing than the first one assert ps.get() == path
def test_koji_promote_wrong_source_type(self, tmpdir, os_env): source = PathSource('path', 'file:///dev/null') tasker, workflow = mock_environment(tmpdir, name='ns/name', version='1.0', release='1', source=source) runner = create_runner(tasker, workflow) with pytest.raises(PluginFailedException): runner.run()
def test_koji_import_wrong_source_type(self, tmpdir, os_env): source = PathSource('path', 'file:///dev/null') tasker, workflow = mock_environment(tmpdir, name='ns/name', version='1.0', release='1', source=source) runner = create_runner(tasker, workflow) with pytest.raises(PluginFailedException) as exc: runner.run() assert "plugin 'koji_import' raised an exception: RuntimeError" in str(exc)
def test_different_custom_base_images(context_dir, build_dir, source_dir): source = PathSource("path", f"file://{DOCKERFILE_MULTISTAGE_CUSTOM_BAD_PATH}", workdir=str(source_dir)) with pytest.raises(NotImplementedError) as exc: DockerBuildWorkflow(context_dir, build_dir, namespace=NAMESPACE, pipeline_run_name=PIPELINE_RUN_NAME, source=source) message = "multiple different custom base images aren't allowed in Dockerfile" assert message in str(exc.value)
def test_copy_from_invalid_index(context_dir, build_dir, source_dir): source = PathSource("path", f"file://{source_dir}", workdir=str(source_dir)) dfp = DockerfileParser(str(source_dir)) dfp.content = dedent("""\ FROM monty as vikings # using an index we haven't seen should break: COPY --from=5 /spam/eggs /bin/eggs """) with pytest.raises(RuntimeError) as exc_info: DockerBuildWorkflow(context_dir, build_dir, namespace=NAMESPACE, pipeline_run_name=PIPELINE_RUN_NAME, source=source) assert "COPY --from=5" in str(exc_info.value)
def test_copy_from_unkown_stage(context_dir, build_dir, source_dir): """test when user has specified COPY --from=image (instead of builder)""" source = PathSource("path", f"file://{source_dir}", workdir=str(source_dir)) dfp = DockerfileParser(str(source_dir)) dfp.content = dedent("""\ FROM monty as vikings FROM python # using a stage name we haven't seen should break: COPY --from=notvikings /spam/eggs /bin/eggs """) with pytest.raises(RuntimeError) as exc_info: DockerBuildWorkflow(context_dir, build_dir, namespace=NAMESPACE, pipeline_run_name=PIPELINE_RUN_NAME, source=source) assert "FROM notvikings AS source" in str(exc_info.value)