Skip to content

Commit

Permalink
refactor: [torrust#581] rename TorrustIndex to Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed May 17, 2024
1 parent 1a28309 commit c71e4a8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::sync::RwLock;
use torrust_index_located_error::{Located, LocatedError};
use url::{ParseError, Url};

pub type TorrustIndex = v1::Settings;
pub type Settings = v1::Settings;
pub type Api = v1::api::Api;
pub type Auth = v1::auth::Auth;
pub type Database = v1::database::Database;
Expand Down Expand Up @@ -225,13 +225,13 @@ impl Tsl {
#[derive(Debug)]
pub struct Configuration {
/// The state of the configuration.
pub settings: RwLock<TorrustIndex>,
pub settings: RwLock<Settings>,
}

impl Default for Configuration {
fn default() -> Configuration {
Configuration {
settings: RwLock::new(TorrustIndex::default()),
settings: RwLock::new(Settings::default()),
}
}
}
Expand All @@ -252,7 +252,7 @@ impl Configuration {
let config_builder = Config::builder()
.add_source(File::from_str(&info.index_toml, FileFormat::Toml))
.build()?;
let mut index_config: TorrustIndex = config_builder.try_deserialize()?;
let mut index_config: Settings = config_builder.try_deserialize()?;

if let Some(ref token) = info.tracker_api_token {
index_config.override_tracker_api_token(token);
Expand All @@ -267,7 +267,7 @@ impl Configuration {
})
}

pub async fn get_all(&self) -> TorrustIndex {
pub async fn get_all(&self) -> Settings {
let settings_lock = self.settings.read().await;

settings_lock.clone()
Expand Down
6 changes: 3 additions & 3 deletions src/services/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::sync::Arc;

use super::user::DbUserRepository;
use crate::config::{Configuration, ConfigurationPublic, TorrustIndex};
use crate::config::{Configuration, ConfigurationPublic, Settings};
use crate::errors::ServiceError;
use crate::models::user::UserId;

Expand All @@ -25,7 +25,7 @@ impl Service {
/// # Errors
///
/// It returns an error if the user does not have the required permissions.
pub async fn get_all(&self, user_id: &UserId) -> Result<TorrustIndex, ServiceError> {
pub async fn get_all(&self, user_id: &UserId) -> Result<Settings, ServiceError> {
let user = self.user_repository.get_compact(user_id).await?;

// Check if user is administrator
Expand All @@ -44,7 +44,7 @@ impl Service {
/// # Errors
///
/// It returns an error if the user does not have the required permissions.
pub async fn get_all_masking_secrets(&self, user_id: &UserId) -> Result<TorrustIndex, ServiceError> {
pub async fn get_all_masking_secrets(&self, user_id: &UserId) -> Result<Settings, ServiceError> {
let user = self.user_repository.get_compact(user_id).await?;

// Check if user is administrator
Expand Down
2 changes: 1 addition & 1 deletion src/web/api/client/v1/contexts/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};

use crate::config::{
Api as DomainApi, Auth as DomainAuth, Database as DomainDatabase, ImageCache as DomainImageCache, Mail as DomainMail,
Network as DomainNetwork, TorrustIndex as DomainSettings, Tracker as DomainTracker,
Network as DomainNetwork, Settings as DomainSettings, Tracker as DomainTracker,
TrackerStatisticsImporter as DomainTrackerStatisticsImporter, Website as DomainWebsite,
};

Expand Down
2 changes: 1 addition & 1 deletion tests/common/contexts/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod responses;
use serde::{Deserialize, Serialize};
use torrust_index::config::{
Api as DomainApi, Auth as DomainAuth, Database as DomainDatabase, ImageCache as DomainImageCache, Mail as DomainMail,
Network as DomainNetwork, TorrustIndex as DomainSettings, Tracker as DomainTracker,
Network as DomainNetwork, Settings as DomainSettings, Tracker as DomainTracker,
TrackerStatisticsImporter as DomainTrackerStatisticsImporter, Website as DomainWebsite,
};

Expand Down
6 changes: 3 additions & 3 deletions tests/environments/app_starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use torrust_index::{app, config};

/// It launches the app and provides a way to stop it.
pub struct AppStarter {
configuration: config::TorrustIndex,
configuration: config::Settings,
/// The application binary state (started or not):
/// - `None`: if the app is not started,
/// - `RunningState`: if the app was started.
Expand All @@ -18,7 +18,7 @@ pub struct AppStarter {

impl AppStarter {
#[must_use]
pub fn with_custom_configuration(configuration: config::TorrustIndex) -> Self {
pub fn with_custom_configuration(configuration: config::Settings) -> Self {
Self {
configuration,
running_state: None,
Expand Down Expand Up @@ -78,7 +78,7 @@ impl AppStarter {
}

#[must_use]
pub fn server_configuration(&self) -> config::TorrustIndex {
pub fn server_configuration(&self) -> config::Settings {
self.configuration.clone()
}

Expand Down
8 changes: 4 additions & 4 deletions tests/environments/isolated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl TestEnv {

/// Provides the whole server configuration.
#[must_use]
pub fn server_configuration(&self) -> config::TorrustIndex {
pub fn server_configuration(&self) -> config::Settings {
self.app_starter.server_configuration()
}

Expand All @@ -69,10 +69,10 @@ impl Default for TestEnv {
}

/// Provides a configuration with ephemeral data for testing.
fn ephemeral(temp_dir: &TempDir) -> config::TorrustIndex {
let mut configuration = config::TorrustIndex {
fn ephemeral(temp_dir: &TempDir) -> config::Settings {
let mut configuration = config::Settings {
log_level: Some("off".to_owned()), // Change to `debug` for tests debugging
..config::TorrustIndex::default()
..config::Settings::default()
};

// Ephemeral API port
Expand Down

0 comments on commit c71e4a8

Please sign in to comment.