@@ -668,6 +668,8 @@ mod tests {
668668 use super :: * ;
669669 use std:: fs;
670670 use tempfile:: TempDir ;
671+ use assert_cmd:: Command ;
672+ use predicates:: prelude:: * ;
671673
672674 #[ test]
673675 fn test_config_load_from_file ( ) {
@@ -747,4 +749,50 @@ enabled = false
747749 assert ! ( loader. config_path. is_none( ) ) ;
748750 assert_eq ! ( loader. config. defaults. format, "human" ) ;
749751 }
752+
753+ #[ test]
754+ fn test_display_sources_verbose_output ( ) {
755+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
756+ let config_path = temp_dir. path ( ) . join ( ".pysentry.toml" ) ;
757+
758+ // Default config without sources specified
759+ let config_content = r#"
760+ version = 1
761+
762+ [cache]
763+ enabled = false
764+
765+ [output]
766+ quiet = false
767+ verbose = true
768+ "# ;
769+ fs:: write ( & config_path, config_content) . unwrap ( ) ;
770+
771+ // Call the pysentry binary with the config file
772+ // Only the default source "pypa" should be displayed
773+ let mut cmd = Command :: cargo_bin ( "pysentry" ) . unwrap ( ) ;
774+ cmd. arg ( "--config" ) . arg ( config_path. to_str ( ) . unwrap ( ) ) ;
775+ cmd. assert ( )
776+ . success ( )
777+ . stderr ( predicate:: str:: contains ( ", sources=[pypa]," ) ) ;
778+
779+ // Add multiple sources to config and save file
780+ let config_content = format ! ( "{}\n {}" ,
781+ config_content,
782+ r#"
783+
784+ [sources]
785+ enabled = ["pypa", "pypi", "osv"]
786+ "# ) ;
787+
788+ fs:: write ( & config_path, config_content) . unwrap ( ) ;
789+
790+ // Call the pysentry binary again with the updated config file
791+ // Now all specified sources should be displayed
792+ let mut cmd = Command :: cargo_bin ( "pysentry" ) . unwrap ( ) ;
793+ cmd. arg ( "--config" ) . arg ( config_path. to_str ( ) . unwrap ( ) ) ;
794+ cmd. assert ( )
795+ . success ( )
796+ . stderr ( predicate:: str:: contains ( ", sources=[pypa, pypi, osv]," ) ) ;
797+ }
750798}
0 commit comments