File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,17 @@ func WithFastFailed() Option {
7171// WithPoolFullErr sets newPoolFullErr to config.
7272func WithPoolFullErr (newPoolFullErr func (ctx context.Context ) error ) Option {
7373 return func (conf * config ) {
74- conf .newPoolFullErrFunc = newPoolFullErr
74+ if newPoolFullErr != nil {
75+ conf .newPoolFullErrFunc = newPoolFullErr
76+ }
7577 }
7678}
7779
7880// WithPoolClosedErr sets newPoolClosedErr to config.
7981func WithPoolClosedErr (newPoolClosedErr func (ctx context.Context ) error ) Option {
8082 return func (conf * config ) {
81- conf .newPoolClosedErrFunc = newPoolClosedErr
83+ if newPoolClosedErr != nil {
84+ conf .newPoolClosedErrFunc = newPoolClosedErr
85+ }
8286 }
8387}
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ func TestWithPoolFullErr(t *testing.T) {
3232 if fmt .Sprintf ("%p" , conf .newPoolFullErrFunc ) != fmt .Sprintf ("%p" , newPoolFullErr ) {
3333 t .Fatalf ("conf.newPoolFullErr %p is wrong" , conf .newPoolFullErrFunc )
3434 }
35+
36+ WithPoolFullErr (nil )(conf )
37+
38+ if fmt .Sprintf ("%p" , conf .newPoolFullErrFunc ) != fmt .Sprintf ("%p" , newPoolFullErr ) {
39+ t .Fatalf ("conf.newPoolFullErr %p is wrong" , conf .newPoolFullErrFunc )
40+ }
3541}
3642
3743// go test -v -cover -run=^TestWithPoolClosedErr$
@@ -46,4 +52,10 @@ func TestWithPoolClosedErr(t *testing.T) {
4652 if fmt .Sprintf ("%p" , conf .newPoolClosedErrFunc ) != fmt .Sprintf ("%p" , newPoolClosedErr ) {
4753 t .Fatalf ("conf.newPoolClosedErr %p is wrong" , conf .newPoolClosedErrFunc )
4854 }
55+
56+ WithPoolClosedErr (nil )(conf )
57+
58+ if fmt .Sprintf ("%p" , conf .newPoolClosedErrFunc ) != fmt .Sprintf ("%p" , newPoolClosedErr ) {
59+ t .Fatalf ("conf.newPoolClosedErr %p is wrong" , conf .newPoolClosedErrFunc )
60+ }
4961}
You can’t perform that action at this time.
0 commit comments