Skip to content

Commit

Permalink
Check if end date is being set to a pending task (GothenburgBitFactor…
Browse files Browse the repository at this point in the history
…y#3622)

check if end date is being set to a pending task

-throw error if end date is being set to a pending task
- add test for the bug
  • Loading branch information
gagankonana authored Sep 13, 2024
1 parent c00c0e9 commit d75ef7f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/commands/CmdModify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ void CmdModify::checkConsistency(Task &before, Task &after) {

if (before.has("recur") && (!after.has("recur") || after.get("recur") == ""))
throw std::string("You cannot remove the recurrence from a recurring task.");

if ((before.getStatus() == Task::pending) && (after.getStatus() == Task::pending) &&
(after.get("end") != ""))
throw format("Could not modify task {1}. You cannot set an end date on a pending task.",
before.identifier(true));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
14 changes: 14 additions & 0 deletions test/modify.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ def test_mod_nop(self):
self.assertIn("Modified 0 tasks.", out)


class TestBug3584(TestCase):
def setUp(self):
self.t = Task()

def test_mod_pending_task_end_date(self):
"""Adding end date for a pending task throws an error"""
self.t("add foo")
code, out, err = self.t.runError("1 modify end:1d")
self.assertIn(
"Could not modify task 1. You cannot set an end date on a pending task.",
err,
)


if __name__ == "__main__":
from simpletap import TAPTestRunner

Expand Down

0 comments on commit d75ef7f

Please sign in to comment.