(t *testing.T)
| 701 | } |
| 702 | |
| 703 | func TestProcessNextItem(t *testing.T) { |
| 704 | tests := []struct { |
| 705 | name string |
| 706 | handler *mockResourceHandler |
| 707 | expectContinue bool |
| 708 | expectCalls int |
| 709 | }{ |
| 710 | { |
| 711 | name: "Successful handler execution", |
| 712 | handler: &mockResourceHandler{ |
| 713 | handleErr: nil, |
| 714 | enqueueTime: time.Now().Add(-10 * time.Millisecond), |
| 715 | }, |
| 716 | expectContinue: true, |
| 717 | expectCalls: 1, |
| 718 | }, |
| 719 | { |
| 720 | name: "Handler returns error", |
| 721 | handler: &mockResourceHandler{ |
| 722 | handleErr: errors.New("test error"), |
| 723 | enqueueTime: time.Now().Add(-10 * time.Millisecond), |
| 724 | }, |
| 725 | expectContinue: true, |
| 726 | expectCalls: 1, |
| 727 | }, |
| 728 | } |
| 729 | |
| 730 | for _, tt := range tests { |
| 731 | t.Run( |
| 732 | tt.name, func(t *testing.T) { |
| 733 | resetGlobalState() |
| 734 | c := newTestController([]string{}, "") |
| 735 | |
| 736 | c.queue.Add(tt.handler) |
| 737 | |
| 738 | result := c.processNextItem() |
| 739 | |
| 740 | assert.Equal(t, tt.expectContinue, result) |
| 741 | assert.Equal(t, tt.expectCalls, tt.handler.handleCalls) |
| 742 | }, |
| 743 | ) |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | func TestProcessNextItemQueueShutdown(t *testing.T) { |
| 748 | resetGlobalState() |
nothing calls this directly
no test coverage detected