@@ -312,6 +312,28 @@ func TestServer(t *testing.T) {
312312 require .Nil (t , err , "error from NewServer: %v" , err )
313313 require .Equal (t , name , s .cfg .appname , "expected appname to be: %v, got: %v" , name , s .cfg .appname )
314314 })
315+ t .Run ("createConnection overwrites WithSocketTimeout" , func (t * testing.T ) {
316+ socketTimeout := 40 * time .Second
317+
318+ s , err := NewServer (
319+ address .Address ("localhost" ),
320+ WithConnectionOptions (func (connOpts ... ConnectionOption ) []ConnectionOption {
321+ return append (
322+ connOpts ,
323+ WithReadTimeout (func (time.Duration ) time.Duration { return socketTimeout }),
324+ WithWriteTimeout (func (time.Duration ) time.Duration { return socketTimeout }),
325+ )
326+ }),
327+ )
328+ assert .Nil (t , err , "NewServer error: %v" , err )
329+
330+ conn , err := s .createConnection ()
331+ assert .Nil (t , err , "createConnection error: %v" , err )
332+
333+ assert .Equal (t , s .cfg .heartbeatTimeout , 10 * time .Second , "expected heartbeatTimeout to be: %v, got: %v" , 10 * time .Second , s .cfg .heartbeatTimeout )
334+ assert .Equal (t , s .cfg .heartbeatTimeout , conn .readTimeout , "expected readTimeout to be: %v, got: %v" , s .cfg .heartbeatTimeout , conn .readTimeout )
335+ assert .Equal (t , s .cfg .heartbeatTimeout , conn .writeTimeout , "expected writeTimeout to be: %v, got: %v" , s .cfg .heartbeatTimeout , conn .writeTimeout )
336+ })
315337}
316338
317339func includesMetadata (t * testing.T , wm []byte ) bool {
0 commit comments