From bc5f50b174b2bbd101f6cbdbc22637d54e19f4b6 Mon Sep 17 00:00:00 2001 From: Jim Madge Date: Fri, 9 Aug 2024 16:01:35 +0100 Subject: [PATCH] Add basic integration tests --- integration_tests/Dockerfile | 6 ++++++ integration_tests/Rprofile | 5 +++++ integration_tests/pip.conf | 3 +++ integration_tests/test.sh | 9 +++++++++ integration_tests/tests/cran.bats | 3 +++ integration_tests/tests/pypi.bats | 5 +++++ 6 files changed, 31 insertions(+) create mode 100644 integration_tests/Dockerfile create mode 100644 integration_tests/Rprofile create mode 100644 integration_tests/pip.conf create mode 100755 integration_tests/test.sh create mode 100644 integration_tests/tests/cran.bats create mode 100644 integration_tests/tests/pypi.bats diff --git a/integration_tests/Dockerfile b/integration_tests/Dockerfile new file mode 100644 index 0000000..69190bd --- /dev/null +++ b/integration_tests/Dockerfile @@ -0,0 +1,6 @@ +FROM bats/bats + +RUN apk add --no-cache --update python3 py3-pip R +RUN mkdir -p /root/.config/pip +COPY pip.conf /root/.config/pip/pip.conf +COPY Rprofile /root/.Rprofile diff --git a/integration_tests/Rprofile b/integration_tests/Rprofile new file mode 100644 index 0000000..104c5c2 --- /dev/null +++ b/integration_tests/Rprofile @@ -0,0 +1,5 @@ +local({ + r <- getOption("repos") + r["CRAN"] <- "http://localhost:8080/repository/cran-proxy" + options(repos=r) +}) diff --git a/integration_tests/pip.conf b/integration_tests/pip.conf new file mode 100644 index 0000000..813fa8c --- /dev/null +++ b/integration_tests/pip.conf @@ -0,0 +1,3 @@ +[global] +index = http://localhost:8080/repository/pypi-proxy/pypi +index-url = http://localhost:8080/repository/pypi-proxy/simple diff --git a/integration_tests/test.sh b/integration_tests/test.sh new file mode 100755 index 0000000..ddaaaf6 --- /dev/null +++ b/integration_tests/test.sh @@ -0,0 +1,9 @@ +#! /usr/bin/env bash +docker build -t nexus_allowlist_bats:latest . +docker run \ + --rm \ + -it \ + -v "$PWD/tests:/code" \ + --network host \ + nexus_allowlist_bats:latest \ + /code diff --git a/integration_tests/tests/cran.bats b/integration_tests/tests/cran.bats new file mode 100644 index 0000000..ab5f064 --- /dev/null +++ b/integration_tests/tests/cran.bats @@ -0,0 +1,3 @@ +@test "Install data.table" { + Rscript -e 'install.packages("data.table")' +} diff --git a/integration_tests/tests/pypi.bats b/integration_tests/tests/pypi.bats new file mode 100644 index 0000000..1b9283e --- /dev/null +++ b/integration_tests/tests/pypi.bats @@ -0,0 +1,5 @@ +@test "Install numpy" { + python3 -m venv ./venv + . ./venv/bin/activate + pip install numpy +}