From 2b3ee83c5e255fc8bfc24355ea1250b3b61919d9 Mon Sep 17 00:00:00 2001 From: Katy Baulch <46493669+katybaulch@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:55:28 +0000 Subject: [PATCH] Added bats container and makefile for bats testing --- .github/tests/bats/Dockerfile | 7 +++++++ .github/tests/bats/README.md | 5 +++++ Makefile | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 .github/tests/bats/Dockerfile create mode 100644 .github/tests/bats/README.md create mode 100644 Makefile diff --git a/.github/tests/bats/Dockerfile b/.github/tests/bats/Dockerfile new file mode 100644 index 0000000..b2e68ca --- /dev/null +++ b/.github/tests/bats/Dockerfile @@ -0,0 +1,7 @@ +FROM bats/bats:latest +RUN apk add git +RUN mkdir /opt/bats-test-helpers +RUN git clone https://github.com/ztombol/bats-support /opt/bats-test-helpers/bats-support +RUN git clone https://github.com/ztombol/bats-assert /opt/bats-test-helpers/bats-assert +RUN git clone https://github.com/lox/bats-mock /opt/bats-test-helpers/lox-bats-mock +WORKDIR /code/ diff --git a/.github/tests/bats/README.md b/.github/tests/bats/README.md new file mode 100644 index 0000000..961c40b --- /dev/null +++ b/.github/tests/bats/README.md @@ -0,0 +1,5 @@ +# bats + +This folder contains the test harness for testing bash scripts. + +Inspired from : [Marck Oemar's Medium post](https://marck-oemar.medium.com/unusual-unit-testing-part-1-bash-scripts-with-bats-55ac78e61491) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0b359d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +build_bats: + docker build .github/tests/bats -t bats-with-helpers:latest + +test_bashscripts: build_bats + docker run --rm -v "${PWD}/.github:/code" bats-with-helpers:latest /code/tests/