MCPcopy Index your code
hub / github.com/stakater/Reloader / TestProcessNextItem

Function TestProcessNextItem

internal/pkg/controller/controller_test.go:703–745  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

701}
702
703func 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
747func TestProcessNextItemQueueShutdown(t *testing.T) {
748 resetGlobalState()

Callers

nothing calls this directly

Calls 5

resetGlobalStateFunction · 0.85
newTestControllerFunction · 0.85
AddMethod · 0.80
processNextItemMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected