Skip to content

Commit b3a1442

Browse files
committed
refactor!: remove unused method in Configuration
1 parent 632c8ba commit b3a1442

File tree

1 file changed

+13
-21
lines changed
  • packages/configuration/src/v1

1 file changed

+13
-21
lines changed

packages/configuration/src/v1/mod.rs

+13-21
Original file line numberDiff line numberDiff line change
@@ -383,21 +383,6 @@ impl Configuration {
383383
}
384384
}
385385

386-
/// Loads the configuration from the configuration file.
387-
///
388-
/// # Errors
389-
///
390-
/// Will return `Err` if `path` does not exist or has a bad configuration.
391-
pub fn load_from_file(path: &str) -> Result<Configuration, Error> {
392-
let figment = Figment::new()
393-
.merge(Toml::file(path))
394-
.merge(Env::prefixed("TORRUST_TRACKER_"));
395-
396-
let config: Configuration = figment.extract()?;
397-
398-
Ok(config)
399-
}
400-
401386
/// Saves the default configuration at the given path.
402387
///
403388
/// # Errors
@@ -459,6 +444,7 @@ impl Configuration {
459444
mod tests {
460445

461446
use crate::v1::Configuration;
447+
use crate::Info;
462448

463449
#[cfg(test)]
464450
fn default_config_toml() -> String {
@@ -550,10 +536,13 @@ mod tests {
550536

551537
#[test]
552538
fn configuration_should_be_loaded_from_a_toml_config_file() {
553-
figment::Jail::expect_with(|jail| {
554-
jail.create_file("tracker.toml", &default_config_toml())?;
539+
figment::Jail::expect_with(|_jail| {
540+
let info = Info {
541+
tracker_toml: default_config_toml(),
542+
api_admin_token: None,
543+
};
555544

556-
let configuration = Configuration::load_from_file("tracker.toml").expect("Could not load configuration from file");
545+
let configuration = Configuration::load(&info).expect("Could not load configuration from file");
557546

558547
assert_eq!(configuration, Configuration::default());
559548

@@ -564,11 +553,14 @@ mod tests {
564553
#[test]
565554
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin() {
566555
figment::Jail::expect_with(|jail| {
567-
jail.create_file("tracker.toml", &default_config_toml())?;
568-
569556
jail.set_env("TORRUST_TRACKER_HTTP_API.ACCESS_TOKENS.ADMIN", "NewToken");
570557

571-
let configuration = Configuration::load_from_file("tracker.toml").expect("Could not load configuration from file");
558+
let info = Info {
559+
tracker_toml: default_config_toml(),
560+
api_admin_token: None,
561+
};
562+
563+
let configuration = Configuration::load(&info).expect("Could not load configuration from file");
572564

573565
assert_eq!(
574566
configuration.http_api.access_tokens.get("admin"),

0 commit comments

Comments
 (0)