(t *testing.T)
| 552 | } |
| 553 | |
| 554 | func TestEdgeCases(t *testing.T) { |
| 555 | work := New(Config{}) |
| 556 | |
| 557 | t.Run("operations on nonexistent jobs", func(t *testing.T) { |
| 558 | // These should not panic |
| 559 | work.StartJob("nonexistent") |
| 560 | work.CompleteJob("nonexistent") |
| 561 | work.FailJob("nonexistent") |
| 562 | work.SetJobCompactionOutput("nonexistent", []string{"output"}) |
| 563 | work.RemoveJob("nonexistent") |
| 564 | |
| 565 | job := work.GetJob("nonexistent") |
| 566 | require.Nil(t, job) |
| 567 | }) |
| 568 | |
| 569 | t.Run("empty work operations", func(t *testing.T) { |
| 570 | emptyWork := New(Config{}) |
| 571 | |
| 572 | require.Equal(t, 0, len(emptyWork.ListJobs())) |
| 573 | require.Empty(t, emptyWork.ListJobs()) |
| 574 | |
| 575 | ctx := context.Background() |
| 576 | foundJob := emptyWork.GetJobForWorker(ctx, "any-worker") |
| 577 | require.Nil(t, foundJob) |
| 578 | |
| 579 | // Prune should not panic on empty work |
| 580 | emptyWork.Prune(ctx) |
| 581 | |
| 582 | // Marshal/unmarshal empty work |
| 583 | data, err := emptyWork.Marshal() |
| 584 | require.NoError(t, err) |
| 585 | |
| 586 | newWork := New(Config{}) |
| 587 | err = newWork.Unmarshal(data) |
| 588 | require.NoError(t, err) |
| 589 | require.Equal(t, 0, len(newWork.ListJobs())) |
| 590 | }) |
| 591 | |
| 592 | t.Run("unmarshal invalid data", func(t *testing.T) { |
| 593 | newWork := New(Config{}) |
| 594 | err := newWork.Unmarshal([]byte("invalid json")) |
| 595 | require.Error(t, err) |
| 596 | }) |
| 597 | } |
| 598 | |
| 599 | // TestFullMarshalUnmarshal tests the full work cache serialization across all shards |
| 600 | func TestFullMarshalUnmarshal(t *testing.T) { |
nothing calls this directly
no test coverage detected