mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Remove duplicate check from task diag (#3545)
This commit is contained in:
parent
6d3519419e
commit
847c482c25
3 changed files with 1 additions and 79 deletions
|
@ -300,35 +300,8 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
<< Context::getContext ().getHeight ()
|
<< Context::getContext ().getHeight ()
|
||||||
<< '\n';
|
<< '\n';
|
||||||
|
|
||||||
// Scan tasks for duplicate UUIDs.
|
|
||||||
auto all = Context::getContext ().tdb2.all_tasks ();
|
|
||||||
std::map <std::string, int> seen;
|
|
||||||
std::vector <std::string> dups;
|
|
||||||
std::string uuid;
|
|
||||||
for (auto& i : all)
|
|
||||||
{
|
|
||||||
uuid = i.get ("uuid");
|
|
||||||
if (seen.find (uuid) != seen.end ())
|
|
||||||
dups.push_back (uuid);
|
|
||||||
else
|
|
||||||
seen[uuid] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
out << " Dups: "
|
|
||||||
<< format ("Scanned {1} tasks for duplicate UUIDs:", all.size ())
|
|
||||||
<< '\n';
|
|
||||||
|
|
||||||
if (dups.size ())
|
|
||||||
{
|
|
||||||
for (auto& d : dups)
|
|
||||||
out << " " << format ("Found duplicate {1}", d) << '\n';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
out << " No duplicates found\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check all the UUID references
|
// Check all the UUID references
|
||||||
|
auto all = Context::getContext ().tdb2.all_tasks ();
|
||||||
|
|
||||||
bool noBrokenRefs = true;
|
bool noBrokenRefs = true;
|
||||||
out << " Broken ref: "
|
out << " Broken ref: "
|
||||||
|
|
|
@ -206,11 +206,6 @@ class TestRecurrenceTasks(TestCase):
|
||||||
code, out, err = self.t("3 delete", input="y\n")
|
code, out, err = self.t("3 delete", input="y\n")
|
||||||
self.assertIn("Deleted 1 task.", out)
|
self.assertIn("Deleted 1 task.", out)
|
||||||
|
|
||||||
# Check for duplicate UUIDs.
|
|
||||||
code, out, err = self.t("diag")
|
|
||||||
self.assertIn("No duplicates found", out)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBug972(TestCase):
|
class TestBug972(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""972: Executed before each test in the class"""
|
"""972: Executed before each test in the class"""
|
||||||
|
@ -478,11 +473,6 @@ class TestBug360AllowedChanges(BaseTestBug360):
|
||||||
expected = "You cannot remove the due date from a recurring task."
|
expected = "You cannot remove the due date from a recurring task."
|
||||||
self.assertNotIn(expected, err)
|
self.assertNotIn(expected, err)
|
||||||
|
|
||||||
# Make sure no duplicate tasks were created
|
|
||||||
code, out, err = self.t.diag()
|
|
||||||
expected = "No duplicates found"
|
|
||||||
self.assertIn(expected, out)
|
|
||||||
|
|
||||||
class TestBug649(TestCase):
|
class TestBug649(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
|
@ -602,11 +592,6 @@ class TestPeriod(TestCase):
|
||||||
self.assertIn(" 2q ", out);
|
self.assertIn(" 2q ", out);
|
||||||
self.assertIn(" 2y ", out);
|
self.assertIn(" 2y ", out);
|
||||||
|
|
||||||
# Duplicate check
|
|
||||||
code, out, err = self.t("diag")
|
|
||||||
self.assertIn("No duplicates found", out)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBugAnnual(TestCase):
|
class TestBugAnnual(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
|
|
|
@ -174,42 +174,6 @@ class TestUUID(TestCase):
|
||||||
self.assertIn('"description":"seven"', out)
|
self.assertIn('"description":"seven"', out)
|
||||||
|
|
||||||
|
|
||||||
class TestUUIDuplicates(TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
"""Executed before each test in the class"""
|
|
||||||
self.t = Task()
|
|
||||||
|
|
||||||
def test_uuid_duplicates_dupe(self):
|
|
||||||
"""Verify that duplicating tasks does not create duplicate UUIDs"""
|
|
||||||
self.t("add simple")
|
|
||||||
self.t("1 duplicate")
|
|
||||||
|
|
||||||
uuids = list()
|
|
||||||
for id in range(1,3):
|
|
||||||
code, out, err = self.t("_get %d.uuid" % id)
|
|
||||||
uuids.append(out.strip())
|
|
||||||
|
|
||||||
self.assertEqual(len(uuids), len(set(uuids)))
|
|
||||||
|
|
||||||
code, out, err = self.t("diag")
|
|
||||||
self.assertIn("No duplicates found", out)
|
|
||||||
|
|
||||||
def test_uuid_duplicates_recurrence(self):
|
|
||||||
"""Verify that recurring tasks do not create duplicate UUIDs"""
|
|
||||||
print(self.t("add periodic recur:daily due:yesterday"))
|
|
||||||
self.t("list") # GC/handleRecurrence
|
|
||||||
|
|
||||||
uuids = list()
|
|
||||||
for id in range(1,5):
|
|
||||||
code, out, err = self.t("_get %d.uuid" % id)
|
|
||||||
uuids.append(out.strip())
|
|
||||||
|
|
||||||
self.assertEqual(len(uuids), len(set(uuids)))
|
|
||||||
|
|
||||||
code, out, err = self.t("diag")
|
|
||||||
self.assertIn("No duplicates found", out)
|
|
||||||
|
|
||||||
|
|
||||||
class TestBug954(TestCase):
|
class TestBug954(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""Executed before each test in the class"""
|
"""Executed before each test in the class"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue