Skip to content

Commit

Permalink
Update test data yaml in e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
bobm-slalom committed Feb 29, 2024
1 parent 1c65730 commit 378e3c7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/end-to-end/testpreservehooks.bats
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# Test to ensure pre-exisiting hooks within the .pre-commit-config.yaml files
# are persisted when installing secureli

MOCK_REPO='tests/test-data/mock-repo'

setup() {
load "${BATS_LIBS_ROOT}/bats-support/load"
load "${BATS_LIBS_ROOT}/bats-assert/load"
mkdir -p $MOCK_REPO
echo '# Ive been here the whole time!' > $MOCK_REPO/.pre-commit-config.yaml
echo '# Existing YAML Contents should persist' > $MOCK_REPO/.pre-commit-config.yaml
echo 'repos:' >> $MOCK_REPO/.pre-commit-config.yaml
echo '- repo: https://github.com/hhatto/autopep8'
echo ' rev: v2.0.4' >> $MOCK_REPO/.pre-commit-config.yaml
echo ' hooks:' >> $MOCK_REPO/.pre-commit-config.yaml
echo ' - id: autopep8' >> $MOCK_REPO/.pre-commit-config.yaml
echo 'print("hello world!")' > $MOCK_REPO/hw.py
run git init $MOCK_REPO
}

@test "can preserve pre-existing hooks" {
run python secureli/main.py init -y --directory $MOCK_REPO
run grep '# Ive been here the whole time!' $MOCK_REPO/.secureli/.pre-commit-config.yaml
assert_output --partial '# Ive been here the whole time!'
run grep '# Existing YAML Contents should persist' $MOCK_REPO/.secureli/.pre-commit-config.yaml
assert_output --partial '# Existing YAML Contents should persist'
}

teardown() {
Expand Down

0 comments on commit 378e3c7

Please sign in to comment.