diff --git a/test/hooks.on-modify.t b/test/hooks.on-modify.t index 9cbc4c901..c4a52801d 100755 --- a/test/hooks.on-modify.t +++ b/test/hooks.on-modify.t @@ -155,6 +155,24 @@ class TestHooksOnModify(TestCase): logs = hook.get_logs() self.assertEqual(logs["output"]["msgs"][0], "FEEDBACK") + def test_onmodify_revert_changes(self): + """on-modify-revert - revert all user modifications.""" + hookname = 'on-modify-revert' + self.t.hooks.add_default(hookname, log=True) + + code, out, err = self.t("add foo") + before = self.t.export() + self.t.faketime("+5s") + code, out, err = self.t("1 modify bar") + after = self.t.export() + + # There should be absolutely _no_ changes. + self.assertEqual(before, after) + + hook = self.t.hooks[hookname] + hook.assertTriggeredCount(1) + hook.assertExitcode(0) + if __name__ == "__main__": from simpletap import TAPTestRunner unittest.main(testRunner=TAPTestRunner()) diff --git a/test/test_hooks/on-modify-revert b/test/test_hooks/on-modify-revert new file mode 100644 index 000000000..0d21a37f8 --- /dev/null +++ b/test/test_hooks/on-modify-revert @@ -0,0 +1,20 @@ +#!/bin/sh + +# The on-modify event is triggered separately for each task modified. This hook +# script can accept/reject the modification. Processing will continue. + +# Input: +# - line of JSON for the original task +# - line of JSON for the modified task, the diff being the modification +read original_task +read modified_task + +# Output: +# - JSON, modified or unmodified. +# - Optional feedback/error. +echo $original_task + +# Status: +# - 0: JSON accepted, non-JSON is feedback. +# - non-0: JSON ignored, non-JSON is error. +exit 0