diff --git a/tests/integration/test_bundler.py b/tests/integration/test_bundler.py index 806c86bd2..f9eafd217 100644 --- a/tests/integration/test_bundler.py +++ b/tests/integration/test_bundler.py @@ -100,3 +100,76 @@ def test_bundler_packages( utils.fetch_deps_and_check_output( tmp_path, test_case, test_params, source_folder, test_data_dir, cachi2_image ) + + +@pytest.mark.parametrize( + "test_params,check_cmd,expected_cmd_output", + [ + pytest.param( + utils.TestParameters( + repo="https://github.com/cachito-testing/cachi2-bundler.git", + ref="well_formed_ruby_all_features", + packages=({"path": ".", "type": "bundler", "allow_binary": "true"},), + flags=["--dev-package-managers"], + check_output=False, + check_deps_checksums=False, + check_vendor_checksums=False, + expected_exit_code=0, + expected_output="", + ), + [], # No additional commands are run to verify the build + [], + id="bundler_everything_present", + ), + pytest.param( + utils.TestParameters( + repo="https://github.com/cachito-testing/cachi2-bundler.git", + ref="well_formed_ruby_without_gemspec", + packages=({"path": ".", "type": "bundler", "allow_binary": "true"},), + flags=["--dev-package-managers"], + check_output=False, + check_deps_checksums=False, + check_vendor_checksums=False, + expected_exit_code=0, + expected_output="", + ), + [], # No additional commands are run to verify the build + [], + id="bundler_everything_present_except_gemspec", + ), + ], +) +def test_e2e_bundler( + test_params: utils.TestParameters, + check_cmd: list[str], + expected_cmd_output: str, + cachi2_image: utils.ContainerImage, + tmp_path: Path, + test_data_dir: Path, + request: pytest.FixtureRequest, +) -> None: + """ + End to end test for bundler. + + :param test_params: Test case arguments + :param tmp_path: Temp directory for pytest + """ + test_case = request.node.callspec.id + + source_folder = utils.clone_repository( + test_params.repo, test_params.ref, f"{test_case}-source", tmp_path + ) + + output_folder = utils.fetch_deps_and_check_output( + tmp_path, test_case, test_params, source_folder, test_data_dir, cachi2_image + ) + + utils.build_image_and_check_cmd( + tmp_path, + output_folder, + test_data_dir, + test_case, + check_cmd, + expected_cmd_output, + cachi2_image, + ) diff --git a/tests/integration/test_data/bundler_everything_present/container/Containerfile b/tests/integration/test_data/bundler_everything_present/container/Containerfile new file mode 100644 index 000000000..d8b657fa9 --- /dev/null +++ b/tests/integration/test_data/bundler_everything_present/container/Containerfile @@ -0,0 +1,19 @@ +FROM docker.io/ruby:3.3 + +# Test disabled network access +RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi + +# Print cachi2 env vars file +RUN cat /tmp/cachi2.env + +# Check bundler deps +RUN ls /tmp/bundler_everything_present-output/deps/bundler + +# Check content of source repository folder +RUN ls /tmp/bundler_everything_present-source/ + +# This should be a COPY, but the source code and Containerfile are in different directories +RUN cp -r /tmp/bundler_everything_present-source /src + +WORKDIR /src +RUN . /tmp/cachi2.env && bundle install diff --git a/tests/integration/test_data/bundler_everything_present_except_gemspec/container/Containerfile b/tests/integration/test_data/bundler_everything_present_except_gemspec/container/Containerfile new file mode 100644 index 000000000..bf95b6e68 --- /dev/null +++ b/tests/integration/test_data/bundler_everything_present_except_gemspec/container/Containerfile @@ -0,0 +1,19 @@ +FROM docker.io/ruby:3.3 + +# Test disabled network access +RUN if curl -IsS www.google.com; then echo "Has network access!"; exit 1; fi + +# Print cachi2 env vars file +RUN cat /tmp/cachi2.env + +# Check bundler deps +RUN ls /tmp/bundler_everything_present_except_gemspec-output/deps/bundler + +# Check content of source repository folder +RUN ls /tmp/bundler_everything_present_except_gemspec-source/ + +# This should be a COPY, but the source code and Containerfile are in different directories +RUN cp -r /tmp/bundler_everything_present_except_gemspec-source /src + +WORKDIR /src +RUN . /tmp/cachi2.env && bundle install