Permalink
Browse files

#21 Move check for empty ID list

- Sharpen error message
- Add test
  • Loading branch information...
lauft committed May 12, 2018
1 parent db13bd4 commit 784ecbbfd90a0432c7a4d5d8a705b3e62bdc7eb4
Showing with 12 additions and 6 deletions.
  1. +5 −6 src/commands/CmdTag.cpp
  2. +7 −0 test/tag.t
@@ -39,12 +39,6 @@ int CmdTag (
{
// Gather IDs and TAGs.
std::set <int> ids = cli.getIds ();

if (ids.empty ())
{
throw std::string ("IDs must be specified. See 'timew help tag'.");
}

std::vector<std::string> tags = cli.getTags ();

// Load the data.
@@ -75,6 +69,11 @@ int CmdTag (
}
}

if (ids.empty ())
{
throw std::string ("At least one ID must be specified. See 'timew help tag'.");
}

// Apply tags to ids.
for (auto& id : ids)
{
@@ -49,6 +49,13 @@ class TestTag(TestCase):
code, out, err = self.t("tag @1 foo")
self.assertIn('Added foo to @1', out)


def test_should_fail_on_missing_id_and_inactive_time_tracking(self):
"""Missing id on inactive time tracking is an error"""
self.t("track yesterday for 1hour")
code, out, err = self.t.runError("tag foo")
self.assertIn("At least one ID 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 784ecbb

Please sign in to comment.