Skip to content

Commit

Permalink
fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Heffernan committed Mar 7, 2024
1 parent 040902d commit 92e577f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions tests/end-to-end/testpreservehooks.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ setup() {
mkdir -p $MOCK_REPO
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 '- repo: https://github.com/hhatto/autopep8' >> $MOCK_REPO/.pre-commit-config.yaml
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 'fail_fast: false' >> $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 '# Existing YAML Contents should persist' $MOCK_REPO/.secureli/.pre-commit-config.yaml
assert_output --partial '# Existing YAML Contents should persist'
run grep 'https://github.com/hhatto/autopep8' $MOCK_REPO/.secureli/.pre-commit-config.yaml
assert_output --partial 'https://github.com/hhatto/autopep8'
run grep 'fail_fast: false' $MOCK_REPO/.secureli/.pre-commit-config.yaml
assert_output --partial 'fail_fast: false'
}

teardown() {
Expand Down
8 changes: 4 additions & 4 deletions tests/services/test_language_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def test_build_pre_commit_respects_existing_pre_commit_config(
with (
patch("builtins.open", mock_open(read_data="data")),
patch.object(
yaml, "safe_load", return_value={"repos": [{"autoPep8": {"version": 0}}]}
yaml, "safe_load", return_value={"repos": [{"autopep8": {"version": 0}}]}
),
):
result = language_support_service.build_pre_commit_config(
Expand All @@ -468,9 +468,9 @@ def test_build_pre_commit_respects_existing_pre_commit_config(
assert result.successful == True
assert result.config_data == {
"repos": [
{"autoPep8": {"version": 0}},
{"autoPep8": {"version": 0}},
{"autoPep8": {"version": 0}},
{"autopep8": {"version": 0}},
{"autopep8": {"version": 0}},
{"autopep8": {"version": 0}},
]
}

Expand Down

0 comments on commit 92e577f

Please sign in to comment.