mirror of
https://github.com/redis/go-redis.git
synced 2025-10-21 20:53:41 +03:00
fix mocks
This commit is contained in:
@@ -10,12 +10,13 @@ import (
|
|||||||
|
|
||||||
// TestHook for testing hook functionality
|
// TestHook for testing hook functionality
|
||||||
type TestHook struct {
|
type TestHook struct {
|
||||||
OnGetCalled int
|
OnGetCalled int
|
||||||
OnPutCalled int
|
OnPutCalled int
|
||||||
GetError error
|
OnRemoveCalled int
|
||||||
PutError error
|
GetError error
|
||||||
ShouldPool bool
|
PutError error
|
||||||
ShouldRemove bool
|
ShouldPool bool
|
||||||
|
ShouldRemove bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (th *TestHook) OnGet(ctx context.Context, conn *Conn, isNewConn bool) error {
|
func (th *TestHook) OnGet(ctx context.Context, conn *Conn, isNewConn bool) error {
|
||||||
@@ -28,6 +29,10 @@ func (th *TestHook) OnPut(ctx context.Context, conn *Conn) (shouldPool bool, sho
|
|||||||
return th.ShouldPool, th.ShouldRemove, th.PutError
|
return th.ShouldPool, th.ShouldRemove, th.PutError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (th *TestHook) OnRemove(ctx context.Context, conn *Conn, reason error) {
|
||||||
|
th.OnRemoveCalled++
|
||||||
|
}
|
||||||
|
|
||||||
func TestPoolHookManager(t *testing.T) {
|
func TestPoolHookManager(t *testing.T) {
|
||||||
manager := NewPoolHookManager()
|
manager := NewPoolHookManager()
|
||||||
|
|
||||||
|
@@ -92,6 +92,10 @@ func (mp *mockPool) Stats() *pool.Stats {
|
|||||||
return &pool.Stats{}
|
return &pool.Stats{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mp *mockPool) Size() int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (mp *mockPool) AddPoolHook(hook pool.PoolHook) {
|
func (mp *mockPool) AddPoolHook(hook pool.PoolHook) {
|
||||||
// Mock implementation - do nothing
|
// Mock implementation - do nothing
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user