TestTaskStorage_DeleteFunc tests the DeleteFunc operation
(t *testing.T)
| 149 | |
| 150 | // TestTaskStorage_DeleteFunc tests the DeleteFunc operation |
| 151 | func TestTaskStorage_DeleteFunc(t *testing.T) { |
| 152 | ts := newTaskStorage() |
| 153 | |
| 154 | task1 := task.NewTask("test1") |
| 155 | task2 := task.NewTask("test2") |
| 156 | task3 := task.NewTask("test3") |
| 157 | |
| 158 | ts.AddLast(task1, task2, task3) |
| 159 | |
| 160 | // Delete tasks where Type is not "test2" |
| 161 | ts.DeleteFunc(func(t task.Task) bool { |
| 162 | return t.GetType() != "test2" |
| 163 | }) |
| 164 | |
| 165 | if ts.Length() != 2 { |
| 166 | t.Errorf("Expected length 2 after DeleteFunc, got %d", ts.Length()) |
| 167 | } |
| 168 | |
| 169 | snapshot := ts.GetSnapshot() |
| 170 | if snapshot[0] != task1 || snapshot[1] != task3 { |
| 171 | t.Error("DeleteFunc failed: incorrect remaining tasks") |
| 172 | } |
| 173 | |
| 174 | // Test DeleteFunc that deletes all |
| 175 | ts.DeleteFunc(func(t task.Task) bool { |
| 176 | return false |
| 177 | }) |
| 178 | |
| 179 | if ts.Length() != 0 { |
| 180 | t.Errorf("Expected length 0 after deleting all, got %d", ts.Length()) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // TestTaskStorage_ProcessResult tests the ProcessResult operation |
| 185 | func TestTaskStorage_ProcessResult(t *testing.T) { |
nothing calls this directly
no test coverage detected