Skip to content

Commit a7d0fda

Browse files
cfsmp3claude
andcommitted
fix: Update test to match master's mark_test_failed implementation
Master uses db.commit() directly instead of safe_db_commit(). Updated test to mock db.commit exception and verify GitHub update is still attempted. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 94f3053 commit a7d0fda

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/test_ci/test_controllers.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,24 +2714,26 @@ def test_safe_db_commit_failure_with_rollback_failure(self, mock_log):
27142714
# Two error logs: one for commit failure, one for rollback failure
27152715
self.assertEqual(mock_log.error.call_count, 2)
27162716

2717-
@mock.patch('mod_ci.controllers.safe_db_commit')
2717+
@mock.patch('mod_ci.controllers.update_status_on_github')
27182718
@mock.patch('run.log')
27192719
def test_mark_test_failed_with_db_commit_failure(
2720-
self, mock_log, mock_safe_commit):
2721-
"""Test mark_test_failed returns False on db commit fail."""
2720+
self, mock_log, mock_update_github):
2721+
"""Test mark_test_failed returns False when DB commit fails but GitHub succeeds."""
27222722
from mod_test.models import Test
27232723

2724-
mock_safe_commit.return_value = False
2725-
27262724
test = Test.query.first()
27272725
mock_db = MagicMock()
2726+
mock_db.commit.side_effect = Exception("DB commit failed")
27282727
mock_repo = MagicMock()
27292728

27302729
result = mark_test_failed(mock_db, test, mock_repo, "Test failed")
27312730

2731+
# DB failed but GitHub succeeded, so result is False
27322732
self.assertFalse(result)
27332733
mock_db.add.assert_called_once()
2734-
mock_safe_commit.assert_called_once()
2734+
mock_db.commit.assert_called_once()
2735+
# GitHub update should still be attempted
2736+
mock_update_github.assert_called_once()
27352737

27362738
@mock.patch('mod_ci.controllers.time.sleep')
27372739
@mock.patch('run.log')

0 commit comments

Comments
 (0)