@@ -383,21 +383,6 @@ impl Configuration {
383
383
}
384
384
}
385
385
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
-
401
386
/// Saves the default configuration at the given path.
402
387
///
403
388
/// # Errors
@@ -459,6 +444,7 @@ impl Configuration {
459
444
mod tests {
460
445
461
446
use crate :: v1:: Configuration ;
447
+ use crate :: Info ;
462
448
463
449
#[ cfg( test) ]
464
450
fn default_config_toml ( ) -> String {
@@ -550,10 +536,13 @@ mod tests {
550
536
551
537
#[ test]
552
538
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
+ } ;
555
544
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" ) ;
557
546
558
547
assert_eq ! ( configuration, Configuration :: default ( ) ) ;
559
548
@@ -564,11 +553,14 @@ mod tests {
564
553
#[ test]
565
554
fn configuration_should_allow_to_overwrite_the_default_tracker_api_token_for_admin ( ) {
566
555
figment:: Jail :: expect_with ( |jail| {
567
- jail. create_file ( "tracker.toml" , & default_config_toml ( ) ) ?;
568
-
569
556
jail. set_env ( "TORRUST_TRACKER_HTTP_API.ACCESS_TOKENS.ADMIN" , "NewToken" ) ;
570
557
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" ) ;
572
564
573
565
assert_eq ! (
574
566
configuration. http_api. access_tokens. get( "admin" ) ,
0 commit comments