Permalink
Browse files

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

- Add test
  • Loading branch information...
lauft committed May 12, 2018
1 parent 784ecbb commit 4afd14ee2eadefae06b3e2747963d44b71686ba0
Showing with 11 additions and 0 deletions.
  1. +5 −0 src/commands/CmdTag.cpp
  2. +6 −0 test/tag.t
@@ -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;
@@ -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")

0 comments on commit 4afd14e

Please sign in to comment.