TestTaskStorage_AddBeforeAfter tests AddBefore and AddAfter operations
(t *testing.T)
| 106 | |
| 107 | // TestTaskStorage_AddBeforeAfter tests AddBefore and AddAfter operations |
| 108 | func TestTaskStorage_AddBeforeAfter(t *testing.T) { |
| 109 | ts := newTaskStorage() |
| 110 | |
| 111 | task1 := task.NewTask("test1") |
| 112 | task2 := task.NewTask("test2") |
| 113 | task3 := task.NewTask("test3") |
| 114 | task4 := task.NewTask("test4") |
| 115 | |
| 116 | // Add initial tasks |
| 117 | ts.AddLast(task1, task2) |
| 118 | |
| 119 | // Test AddAfter |
| 120 | ts.AddAfter(task1.GetId(), task3) |
| 121 | snapshot := ts.GetSnapshot() |
| 122 | if len(snapshot) != 3 { |
| 123 | t.Errorf("Expected 3 tasks, got %d", len(snapshot)) |
| 124 | } |
| 125 | |
| 126 | if snapshot[0] != task1 || snapshot[1] != task3 || snapshot[2] != task2 { |
| 127 | t.Error("AddAfter failed: incorrect order") |
| 128 | } |
| 129 | |
| 130 | // Test AddBefore |
| 131 | ts.AddBefore(task2.GetId(), task4) |
| 132 | snapshot = ts.GetSnapshot() |
| 133 | if len(snapshot) != 4 { |
| 134 | t.Errorf("Expected 4 tasks, got %d", len(snapshot)) |
| 135 | } |
| 136 | |
| 137 | if snapshot[0] != task1 || snapshot[1] != task3 || snapshot[2] != task4 || snapshot[3] != task2 { |
| 138 | t.Error("AddBefore failed: incorrect order") |
| 139 | } |
| 140 | |
| 141 | // Test AddAfter/AddBefore with non-existent ID |
| 142 | ts.AddAfter("nonexistent", task.NewTask("should-not-be-added")) |
| 143 | ts.AddBefore("nonexistent", task.NewTask("should-not-be-added")) |
| 144 | |
| 145 | if ts.Length() != 4 { |
| 146 | t.Errorf("Expected length 4 (no tasks should be added for non-existent IDs), got %d", ts.Length()) |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // TestTaskStorage_DeleteFunc tests the DeleteFunc operation |
| 151 | func TestTaskStorage_DeleteFunc(t *testing.T) { |
nothing calls this directly
no test coverage detected