@@ -278,3 +278,60 @@ func TestHealthCheck(t *testing.T) {
278278 t .Fatalf ("expected 0 memories, got %d" , report .MemoriesTotal )
279279 }
280280}
281+
282+ func TestTaskChildrenCompleteWithInterleavedSortOrder (t * testing.T ) {
283+ d := setupTestDB (t )
284+ pdir := "/test/project"
285+
286+ tasks := []map [string ]interface {}{
287+ {"title" : "Group 1" , "children" : []interface {}{
288+ map [string ]interface {}{"title" : "1.1" },
289+ map [string ]interface {}{"title" : "1.2" },
290+ map [string ]interface {}{"title" : "1.3" },
291+ map [string ]interface {}{"title" : "1.4" },
292+ map [string ]interface {}{"title" : "1.5" },
293+ map [string ]interface {}{"title" : "1.6" },
294+ }},
295+ {"title" : "Group 2" , "children" : []interface {}{
296+ map [string ]interface {}{"title" : "2.1" },
297+ map [string ]interface {}{"title" : "2.2" },
298+ map [string ]interface {}{"title" : "2.3" },
299+ map [string ]interface {}{"title" : "2.4" },
300+ map [string ]interface {}{"title" : "2.5" },
301+ }},
302+ {"title" : "Group 3" , "children" : []interface {}{
303+ map [string ]interface {}{"title" : "3.1" },
304+ map [string ]interface {}{"title" : "3.2" },
305+ map [string ]interface {}{"title" : "3.3" },
306+ }},
307+ }
308+
309+ _ , err := d .CreateTasks (pdir , "multi-group" , tasks , "manual" )
310+ if err != nil {
311+ t .Fatalf ("CreateTasks: %v" , err )
312+ }
313+
314+ groups , err := d .GetTasks (pdir , "" , "" , "" )
315+ if err != nil {
316+ t .Fatalf ("GetTasks: %v" , err )
317+ }
318+ if len (groups ) != 1 {
319+ t .Fatalf ("expected 1 feature group, got %d" , len (groups ))
320+ }
321+
322+ g := groups [0 ]
323+ if len (g .Tasks ) != 3 {
324+ t .Fatalf ("expected 3 parent tasks, got %d" , len (g .Tasks ))
325+ }
326+
327+ expected := map [string ]int {"Group 1" : 6 , "Group 2" : 5 , "Group 3" : 3 }
328+ for _ , task := range g .Tasks {
329+ want , ok := expected [task .Title ]
330+ if ! ok {
331+ t .Fatalf ("unexpected parent task: %s" , task .Title )
332+ }
333+ if len (task .Children ) != want {
334+ t .Fatalf ("%s: expected %d children, got %d" , task .Title , want , len (task .Children ))
335+ }
336+ }
337+ }
0 commit comments