Skip to content

Commit

Permalink
test_helper: make test setup more hermetic
Browse files Browse the repository at this point in the history
When running tests locally outside of a container (e.g. git clone
git-secrets; make test), if a user is already using git-secrets by
default in their system config and default gitdir template, tests which
expect not to have git-secrets installed will fail. Instead, let's
remove all hooks when we create a directory without the testbench's
template and ignore the system config which may contain patterns that
conflict with the testbench.
  • Loading branch information
nasamuffin committed Mar 17, 2020
1 parent 5e28df3 commit 8ead034
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/test_helper.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Disallow any system-level git-secret pattern configs
export GIT_CONFIG_NOSYSTEM="true"
export TEST_REPO="$BATS_TMPDIR/test-repo"
export TEMP_HOME="$BATS_TMPDIR/home"
export TEMPLATE_DIR="${BATS_TMPDIR}/template"
Expand Down Expand Up @@ -31,6 +33,9 @@ setup_repo() {
mkdir -p $TEST_REPO
cd $TEST_REPO
git init
# Uninstall any hooks present in the system template which could interfere
# with git-secrets
rm -fr .git/hooks/*
git config --local --add secrets.patterns '@todo'
git config --local --add secrets.patterns 'forbidden|me'
git config --local --add secrets.patterns '#hash'
Expand Down

0 comments on commit 8ead034

Please sign in to comment.