#21 Let command 'tag' fail on no tags given

- Add test
This commit is contained in:
Thomas Lauf 2018-05-12 19:17:55 +02:00 committed by lauft
parent 784ecbbfd9
commit 4afd14ee2e
2 changed files with 11 additions and 0 deletions

View file

@ -41,6 +41,11 @@ int CmdTag (
std::set <int> ids = cli.getIds ();
std::vector<std::string> tags = cli.getTags ();
if (tags.empty ())
{
throw std::string ("At least one tag must be specified. See 'timew help tag'.");
}
// Load the data.
// Note: There is no filter.
Interval filter;

View file

@ -56,6 +56,12 @@ class TestTag(TestCase):
code, out, err = self.t.runError("tag foo")
self.assertIn("At least one ID must be specified.", err)
def test_should_fail_on_no_tags(self):
"""No tags is an error"""
self.t("track yesterday for 1hour")
code, out, err = self.t.runError("tag @1")
self.assertIn("At least one tag must be specified.", err)
def test_add_tag_to_closed_interval(self):
"""Add a tag to an closed interval"""
self.t("track yesterday for 1hour")