@@ -16,7 +16,7 @@ use matrix_sdk::{
1616 api:: client:: { account:: register:: v3:: Request as RegistrationRequest , uiaa} ,
1717 OwnedDeviceId , OwnedUserId ,
1818 } ,
19- Client ,
19+ Client , ClientBuilder ,
2020} ;
2121use once_cell:: sync:: Lazy ;
2222use rand:: Rng as _;
@@ -79,9 +79,7 @@ impl TestClientBuilder {
7979 self
8080 }
8181
82- /// Create a new Client that is a copy of the supplied one, created using
83- /// [`Client::restore_session`].
84- pub async fn duplicate ( self , other : & Client ) -> Result < Client > {
82+ fn common_client_builder ( & self ) -> ClientBuilder {
8583 let homeserver_url =
8684 option_env ! ( "HOMESERVER_URL" ) . unwrap_or ( "http://localhost:8228" ) . to_owned ( ) ;
8785 let sliding_sync_proxy_url =
@@ -94,10 +92,18 @@ impl TestClientBuilder {
9492 . with_encryption_settings ( self . encryption_settings )
9593 . request_config ( RequestConfig :: short_retry ( ) ) ;
9694
97- if let Some ( proxy) = self . http_proxy {
95+ if let Some ( proxy) = & self . http_proxy {
9896 client_builder = client_builder. proxy ( proxy) ;
9997 }
10098
99+ client_builder
100+ }
101+
102+ /// Create a new Client that is a copy of the supplied one, created using
103+ /// [`Client::restore_session`].
104+ pub async fn duplicate ( self , other : & Client ) -> Result < Client > {
105+ let client_builder = self . common_client_builder ( ) ;
106+
101107 let client = match self . use_sqlite_dir {
102108 Some ( SqlitePath :: Path ( path_buf) ) => {
103109 client_builder. sqlite_store ( & path_buf, None ) . build ( ) . await ?
@@ -120,24 +126,9 @@ impl TestClientBuilder {
120126 pub async fn build ( self ) -> Result < Client > {
121127 let mut users = USERS . lock ( ) . await ;
122128
123- let homeserver_url =
124- option_env ! ( "HOMESERVER_URL" ) . unwrap_or ( "http://localhost:8228" ) . to_owned ( ) ;
125- let sliding_sync_proxy_url =
126- option_env ! ( "SLIDING_SYNC_PROXY_URL" ) . unwrap_or ( "http://localhost:8338" ) . to_owned ( ) ;
127-
128129 let tmp_dir = tempdir ( ) ?;
129130
130- let mut client_builder = Client :: builder ( )
131- . user_agent ( "matrix-sdk-integration-tests" )
132- . homeserver_url ( homeserver_url)
133- . sliding_sync_proxy ( sliding_sync_proxy_url)
134- . with_encryption_settings ( self . encryption_settings )
135- . request_config ( RequestConfig :: short_retry ( ) ) ;
136-
137- if let Some ( proxy) = self . http_proxy {
138- client_builder = client_builder. proxy ( proxy) ;
139- }
140-
131+ let client_builder = self . common_client_builder ( ) ;
141132 let client = match self . use_sqlite_dir {
142133 None => client_builder. build ( ) . await ?,
143134 Some ( SqlitePath :: Random ) => {
0 commit comments