Skip to content

Commit

Permalink
Added bats container and makefile for bats testing
Browse files Browse the repository at this point in the history
  • Loading branch information
katybaulch committed Mar 4, 2024
1 parent 1edd7bb commit 2b3ee83
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/tests/bats/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
5 changes: 5 additions & 0 deletions .github/tests/bats/README.md
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit 2b3ee83

Please sign in to comment.