TestTaskStorage_EdgeCases tests various edge cases
(t *testing.T)
| 527 | |
| 528 | // TestTaskStorage_EdgeCases tests various edge cases |
| 529 | func TestTaskStorage_EdgeCases(t *testing.T) { |
| 530 | ts := newTaskStorage() |
| 531 | |
| 532 | // Test operations on empty storage |
| 533 | if ts.RemoveFirst() != nil { |
| 534 | t.Error("RemoveFirst on empty storage should return nil") |
| 535 | } |
| 536 | |
| 537 | if ts.RemoveLast() != nil { |
| 538 | t.Error("RemoveLast on empty storage should return nil") |
| 539 | } |
| 540 | |
| 541 | if ts.Remove("nonexistent") != nil { |
| 542 | t.Error("Remove nonexistent ID should return nil") |
| 543 | } |
| 544 | |
| 545 | // Test AddAfter/AddBefore with empty storage |
| 546 | ts.AddAfter("nonexistent", task.NewTask("test")) |
| 547 | ts.AddBefore("nonexistent", task.NewTask("test")) |
| 548 | |
| 549 | if ts.Length() != 0 { |
| 550 | t.Error("Adding after/before nonexistent IDs in empty storage should not add tasks") |
| 551 | } |
| 552 | |
| 553 | // Test with single task |
| 554 | singleTask := task.NewTask("single") |
| 555 | ts.AddLast(singleTask) |
| 556 | |
| 557 | if ts.GetFirst() != singleTask { |
| 558 | t.Error("Single task should be both first and last") |
| 559 | } |
| 560 | |
| 561 | if ts.GetLast() != singleTask { |
| 562 | t.Error("Single task should be both first and last") |
| 563 | } |
| 564 | |
| 565 | // Remove the single task |
| 566 | if ts.RemoveFirst() != singleTask { |
| 567 | t.Error("RemoveFirst should return the single task") |
| 568 | } |
| 569 | |
| 570 | if ts.Length() != 0 { |
| 571 | t.Error("Storage should be empty after removing single task") |
| 572 | } |
| 573 | |
| 574 | // Test ProcessResult with non-existent task |
| 575 | result := &TaskResult{Status: Success} |
| 576 | result.AddHeadTasks(task.NewTask("head")) |
| 577 | ts.ProcessResult(*result, task.NewTask("nonexistent")) |
| 578 | |
| 579 | // Should still add head tasks even if target task doesn't exist |
| 580 | if ts.Length() != 1 { |
| 581 | t.Errorf("Expected 1 task after ProcessResult with non-existent task, got %d", ts.Length()) |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | // TestTaskStorage_LargeScaleOperations tests performance and correctness with many operations |
| 586 | func TestTaskStorage_LargeScaleOperations(t *testing.T) { |
nothing calls this directly
no test coverage detected