diff options
Diffstat (limited to 'Omni/Task.hs')
| -rw-r--r-- | Omni/Task.hs | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/Omni/Task.hs b/Omni/Task.hs index d1e672a..24e528b 100644 --- a/Omni/Task.hs +++ b/Omni/Task.hs @@ -312,7 +312,47 @@ unitTests = ready <- getReadyTasks -- Both should be ready since Related doesn't block (taskId task1 `elem` map taskId ready) Test.@?= True - (taskId task2 `elem` map taskId ready) Test.@?= True + (taskId task2 `elem` map taskId ready) Test.@?= True, + Test.unit "child task gets sequential ID" <| do + parent <- createTask "Parent" Epic Nothing Nothing P2 [] + child1 <- createTask "Child 1" WorkTask (Just (taskId parent)) Nothing P2 [] + child2 <- createTask "Child 2" WorkTask (Just (taskId parent)) Nothing P2 [] + taskId child1 Test.@?= taskId parent <> ".1" + taskId child2 Test.@?= taskId parent <> ".2", + Test.unit "grandchild task gets sequential ID" <| do + parent <- createTask "Grandparent" Epic Nothing Nothing P2 [] + child <- createTask "Parent" Epic (Just (taskId parent)) Nothing P2 [] + grandchild <- createTask "Grandchild" WorkTask (Just (taskId child)) Nothing P2 [] + taskId grandchild Test.@?= taskId parent <> ".1.1", + Test.unit "siblings of grandchild task get sequential ID" <| do + parent <- createTask "Grandparent" Epic Nothing Nothing P2 [] + child <- createTask "Parent" Epic (Just (taskId parent)) Nothing P2 [] + grandchild1 <- createTask "Grandchild 1" WorkTask (Just (taskId child)) Nothing P2 [] + grandchild2 <- createTask "Grandchild 2" WorkTask (Just (taskId child)) Nothing P2 [] + taskId grandchild1 Test.@?= taskId parent <> ".1.1" + taskId grandchild2 Test.@?= taskId parent <> ".1.2", + Test.unit "child ID generation skips gaps" <| do + parent <- createTask "Parent with gaps" Epic Nothing Nothing P2 [] + child1 <- createTask "Child 1" WorkTask (Just (taskId parent)) Nothing P2 [] + -- Manually create a task with .3 suffix to simulate a gap (or deleted task) + let child3Id = taskId parent <> ".3" + child3 = Task + { taskId = child3Id, + taskTitle = "Child 3", + taskType = WorkTask, + taskParent = Just (taskId parent), + taskNamespace = Nothing, + taskStatus = Open, + taskPriority = P2, + taskDependencies = [], + taskCreatedAt = taskCreatedAt child1, + taskUpdatedAt = taskUpdatedAt child1 + } + saveTask child3 + + -- Create a new child, it should get .4, not .2 + child4 <- createTask "Child 4" WorkTask (Just (taskId parent)) Nothing P2 [] + taskId child4 Test.@?= taskId parent <> ".4" ] -- | Test CLI argument parsing to ensure docopt string matches actual usage |
