(t *testing.T)
| 104 | } |
| 105 | |
| 106 | func TestHookErrorHandling(t *testing.T) { |
| 107 | manager := NewPoolHookManager() |
| 108 | |
| 109 | // Hook that returns error on Get |
| 110 | errorHook := &TestHook{ |
| 111 | GetError: errors.New("test error"), |
| 112 | ShouldPool: true, |
| 113 | ShouldAccept: true, |
| 114 | } |
| 115 | |
| 116 | normalHook := &TestHook{ShouldPool: true, ShouldAccept: true} |
| 117 | |
| 118 | manager.AddHook(errorHook) |
| 119 | manager.AddHook(normalHook) |
| 120 | |
| 121 | ctx := context.Background() |
| 122 | conn := &Conn{} |
| 123 | |
| 124 | // Test that error stops processing |
| 125 | accept, err := manager.ProcessOnGet(ctx, conn, false) |
| 126 | if err == nil { |
| 127 | t.Error("Expected error from ProcessOnGet") |
| 128 | } |
| 129 | if accept { |
| 130 | t.Error("Expected accept to be false") |
| 131 | } |
| 132 | |
| 133 | if errorHook.OnGetCalled != 1 { |
| 134 | t.Errorf("Expected errorHook.OnGetCalled to be 1, got %d", errorHook.OnGetCalled) |
| 135 | } |
| 136 | |
| 137 | // normalHook should not be called due to error |
| 138 | if normalHook.OnGetCalled != 0 { |
| 139 | t.Errorf("Expected normalHook.OnGetCalled to be 0, got %d", normalHook.OnGetCalled) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func TestHookShouldRemove(t *testing.T) { |
| 144 | manager := NewPoolHookManager() |
nothing calls this directly
no test coverage detected