File tree Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Expand file tree Collapse file tree 1 file changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -94,28 +94,39 @@ async fn test_aborted_command() {
94
94
async fn test_recycled ( ) {
95
95
let pool = create_pool ( ) ;
96
96
97
- let client_id = {
98
- let mut conn = pool. get ( ) . await . unwrap ( ) ;
97
+ let connection_name = "unique_connection_name" ;
99
98
99
+ let connection_details_1 = {
100
+ let mut conn = pool. get ( ) . await . unwrap ( ) ;
100
101
cmd ( "CLIENT" )
101
- . arg ( "ID" )
102
- . query_async :: < i64 > ( & mut conn)
102
+ . arg ( "SETNAME" )
103
+ . arg ( connection_name)
104
+ . query_async :: < ( ) > ( & mut conn)
103
105
. await
104
- . unwrap ( )
106
+ . unwrap ( ) ;
107
+
108
+ let current_name: Option < String > = cmd ( "CLIENT" )
109
+ . arg ( "GETNAME" )
110
+ . query_async ( & mut conn)
111
+ . await
112
+ . unwrap ( ) ;
113
+
114
+ current_name
105
115
} ;
106
116
107
- {
117
+ let connection_details_2 = {
108
118
let mut conn = pool. get ( ) . await . unwrap ( ) ;
109
-
110
- let new_client_id = cmd ( "CLIENT" )
111
- . arg ( "ID" )
112
- . query_async :: < i64 > ( & mut conn)
119
+ let current_name: Option < String > = cmd ( "CLIENT" )
120
+ . arg ( "GETNAME" )
121
+ . query_async ( & mut conn)
113
122
. await
114
123
. unwrap ( ) ;
115
124
116
- assert_eq ! (
117
- client_id, new_client_id,
118
- "the redis connection was not recycled"
119
- ) ;
120
- }
125
+ current_name
126
+ } ;
127
+
128
+ assert_eq ! (
129
+ connection_details_1, connection_details_2,
130
+ "The Redis connection was not recycled: different connection name"
131
+ ) ;
121
132
}
You can’t perform that action at this time.
0 commit comments