test: require TEST_PR_ID for write integration tests to prevent accidental mutations

Write tests no longer pick a random open PR. RUN_WRITE_TESTS=true alone is not
sufficient — TEST_PR_ID must also be set, otherwise each write test is skipped
with a warning. Added try/finally cleanup blocks so approval/comment/task state
is always restored even on assertion failures. Updated .env.example and README
to document the new requirement.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 23:25:40 +02:00
parent ab73c92e6d
commit 9c7d983df4
3 changed files with 50 additions and 34 deletions

11
.env.example Normal file
View File

@@ -0,0 +1,11 @@
BITBUCKET_MCP_EMAIL=your_email@example.com
BITBUCKET_MCP_TOKEN=your_api_token
DEFAULT_WORKSPACE=your-workspace
DEFAULT_REPO=your-repo
# Integration test write operations
# Set RUN_WRITE_TESTS=true to enable tests that create/modify/delete data.
# TEST_PR_ID must also be set — write tests will only run against this specific PR
# to avoid accidentally modifying unrelated pull requests.
# RUN_WRITE_TESTS=true
# TEST_PR_ID=123