Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 622c6bf

Browse files
committedJan 22, 2025··
refactor: [#1198] remove duplicate code in app init in tests
1 parent 82097b0 commit 622c6bf

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed
 

‎src/bootstrap/jobs/http_tracker.rs

+6-30
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,8 @@ mod tests {
108108

109109
use torrust_tracker_test_helpers::configuration::ephemeral_public;
110110

111-
use crate::bootstrap::app::initialize_global_services;
111+
use crate::bootstrap::app::{initialize_app_container, initialize_global_services};
112112
use crate::bootstrap::jobs::http_tracker::start_job;
113-
use crate::core::authentication::handler::KeysHandler;
114-
use crate::core::authentication::key::repository::in_memory::InMemoryKeyRepository;
115-
use crate::core::authentication::key::repository::persisted::DatabaseKeyRepository;
116-
use crate::core::authentication::service;
117-
use crate::core::services::{initialize_database, initialize_tracker, statistics};
118-
use crate::core::whitelist;
119-
use crate::core::whitelist::repository::in_memory::InMemoryWhitelist;
120113
use crate::servers::http::Version;
121114
use crate::servers::registar::Registar;
122115

@@ -126,35 +119,18 @@ mod tests {
126119
let http_tracker = cfg.http_trackers.clone().expect("missing HTTP tracker configuration");
127120
let config = &http_tracker[0];
128121

129-
let (stats_event_sender, _stats_repository) = statistics::setup::factory(cfg.core.tracker_usage_statistics);
130-
let stats_event_sender = Arc::new(stats_event_sender);
131-
132122
initialize_global_services(&cfg);
133123

134-
let database = initialize_database(&cfg);
135-
let in_memory_whitelist = Arc::new(InMemoryWhitelist::default());
136-
let whitelist_authorization = Arc::new(whitelist::authorization::Authorization::new(
137-
&cfg.core,
138-
&in_memory_whitelist.clone(),
139-
));
140-
let db_key_repository = Arc::new(DatabaseKeyRepository::new(&database));
141-
let in_memory_key_repository = Arc::new(InMemoryKeyRepository::default());
142-
let authentication_service = Arc::new(service::AuthenticationService::new(&cfg.core, &in_memory_key_repository));
143-
let _keys_handler = Arc::new(KeysHandler::new(
144-
&db_key_repository.clone(),
145-
&in_memory_key_repository.clone(),
146-
));
147-
148-
let tracker = Arc::new(initialize_tracker(&cfg, &database, &whitelist_authorization));
124+
let app_container = initialize_app_container(&cfg);
149125

150126
let version = Version::V1;
151127

152128
start_job(
153129
config,
154-
tracker,
155-
authentication_service,
156-
whitelist_authorization,
157-
stats_event_sender,
130+
app_container.tracker,
131+
app_container.authentication_service,
132+
app_container.whitelist_authorization,
133+
app_container.stats_event_sender,
158134
Registar::default().give_form(),
159135
version,
160136
)

0 commit comments

Comments
 (0)
Please sign in to comment.