diff --git a/tests/end-to-end/testpreservehooks.bats b/tests/end-to-end/testpreservehooks.bats index 6f92ed2c..17921df2 100644 --- a/tests/end-to-end/testpreservehooks.bats +++ b/tests/end-to-end/testpreservehooks.bats @@ -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() {