Add event-driven reporting and durable failure recovery hooks
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import tempfile
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts'))
|
||||
import hooks
|
||||
|
||||
|
||||
class HookCliTests(unittest.TestCase):
|
||||
def test_first_success_does_not_emit_nonexistent_recovery(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
config=Path(root)/'private.json';config.write_text('{}')
|
||||
args=['hooks.py','--config',str(config),'--source','check','--event-id','first','--summary','check','--','program']
|
||||
c=SimpleNamespace(call=lambda *args:None)
|
||||
with patch.object(sys,'argv',args),patch.object(hooks,'Client',return_value=c),patch.object(c,'call') as call,patch.object(hooks.subprocess,'run',return_value=SimpleNamespace(returncode=0)):
|
||||
self.assertEqual(hooks.main(),0)
|
||||
call.assert_not_called()
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in New Issue
Block a user