mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
TI-6: Exception after shortening task.
- Thanks to Sergey Trofimov.
This commit is contained in:
parent
ec84fd447c
commit
da9b2a7fdb
3 changed files with 32 additions and 4 deletions
|
@ -11,6 +11,8 @@
|
|||
(thanks to Tomas Babej).
|
||||
- TI-5 Unicode tags not working.
|
||||
(thanks to Sergey Trofimov).
|
||||
- TI-6 Exception after shortening task.
|
||||
(thanks to Sergey Trofimov).
|
||||
- Added 'continue' command.
|
||||
- Added 'diagnostics' command.
|
||||
- Added 'export' command.
|
||||
|
|
|
@ -67,6 +67,8 @@ int CmdShorten (
|
|||
if (! i.range.is_open ())
|
||||
{
|
||||
Duration dur (delta);
|
||||
if (dur < (i.range.end - i.range.start))
|
||||
{
|
||||
i.range.end -= dur.toTime_t ();
|
||||
|
||||
database.modifyInterval (tracked[tracked.size () - id], i);
|
||||
|
@ -74,6 +76,15 @@ int CmdShorten (
|
|||
// Feedback.
|
||||
std::cout << "Shortened @" << id << " by " << dur.formatHours () << '\n';
|
||||
}
|
||||
else
|
||||
std::cout << "Cannot shorten interval @"
|
||||
<< id
|
||||
<< " by "
|
||||
<< dur.formatHours ()
|
||||
<< " because it is only "
|
||||
<< Duration (i.range.end - i.range.start).formatHours ()
|
||||
<< " in length.\n";
|
||||
}
|
||||
else
|
||||
std::cout << "Cannot shorten open interval @" << id << '\n';
|
||||
}
|
||||
|
|
|
@ -70,6 +70,21 @@ class TestShorten(TestCase):
|
|||
|
||||
# TODO Add :adjust tests.
|
||||
|
||||
class TestBug6(TestCase):
|
||||
def setUp(self):
|
||||
"""Executed before each test in the class"""
|
||||
self.t = Timew()
|
||||
|
||||
def test_over_shorten_closed_interval(self):
|
||||
"""TI-6: Exception after shortening task.
|
||||
|
||||
When an interval is shortened by an amount that exceeds it's length,
|
||||
an assert is triggered, and should be an error instead.
|
||||
"""
|
||||
self.t("track 2016-06-08T07:30:00 - 2016-06-08T07:35:00 foo")
|
||||
code, out, err = self.t("shorten @1 10mins")
|
||||
self.assertIn('Cannot shorten interval @1 by 0:10:00 because it is only 0:05:00 in length.', out)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue