Skip to content

Commit

Permalink
Throw error if trying to set end date for a pending task
Browse files Browse the repository at this point in the history
-throw error if end date is set for pending task
-tests
  • Loading branch information
gagankonana committed Sep 13, 2024
1 parent c00c0e9 commit 5900554
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,10 @@ void Task::validate(bool applyDefault /* = true */) {
setAsNow("end");

// Pending tasks cannot have an end date, remove if present
if ((status == Task::pending) && (get("end") != "")) remove("end");
if ((status == Task::pending) && (get("end") != "")) {
remove("end");
throw format("Could not modify task {1}. You cannot set an end date on a pending task.", this->id);
}

// Provide a modified date unless user already specified one.
if (!has("modified") || get("modified") == "") setAsNow("modified");
Expand Down
10 changes: 10 additions & 0 deletions test/modify.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def test_mod_nop(self):
code, out, err = self.t("1 modify due:")
self.assertIn("Modified 0 tasks.", out)

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

def test_mod_pending_task_end_date(self):
"""Adding the 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 5900554

Please sign in to comment.