(t *testing.T)
| 141 | } |
| 142 | |
| 143 | func TestHookShouldRemove(t *testing.T) { |
| 144 | manager := NewPoolHookManager() |
| 145 | |
| 146 | // Hook that says to remove connection |
| 147 | removeHook := &TestHook{ |
| 148 | ShouldPool: false, |
| 149 | ShouldRemove: true, |
| 150 | ShouldAccept: true, |
| 151 | } |
| 152 | |
| 153 | normalHook := &TestHook{ShouldPool: true, ShouldAccept: true} |
| 154 | |
| 155 | manager.AddHook(removeHook) |
| 156 | manager.AddHook(normalHook) |
| 157 | |
| 158 | ctx := context.Background() |
| 159 | conn := &Conn{} |
| 160 | |
| 161 | shouldPool, shouldRemove, err := manager.ProcessOnPut(ctx, conn) |
| 162 | if err != nil { |
| 163 | t.Errorf("ProcessOnPut should not error: %v", err) |
| 164 | } |
| 165 | |
| 166 | if shouldPool { |
| 167 | t.Error("Expected shouldPool to be false") |
| 168 | } |
| 169 | |
| 170 | if !shouldRemove { |
| 171 | t.Error("Expected shouldRemove to be true") |
| 172 | } |
| 173 | |
| 174 | if removeHook.OnPutCalled != 1 { |
| 175 | t.Errorf("Expected removeHook.OnPutCalled to be 1, got %d", removeHook.OnPutCalled) |
| 176 | } |
| 177 | |
| 178 | // normalHook should not be called due to early return |
| 179 | if normalHook.OnPutCalled != 0 { |
| 180 | t.Errorf("Expected normalHook.OnPutCalled to be 0, got %d", normalHook.OnPutCalled) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | func TestPoolWithHooks(t *testing.T) { |
| 185 | // Create a pool with hooks |
nothing calls this directly
no test coverage detected