Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 103 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ toml = "0.9.7"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }
zip = { version = "5.1.1", default-features = false, features = ["deflate"] }

[dev-dependencies]
assert_cmd = "2.0.17"
predicates = "3.1.3"
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,11 @@ pub async fn audit(

if audit_args.verbose {
eprintln!(
"Configuration: format={:?}, severity={:?}, fail_on={:?}, source={:?}, scope='{}', direct_only={}",
"Configuration: format={:?}, severity={:?}, fail_on={:?}, sources=[{}], scope='{}', direct_only={}",
audit_args.format,
audit_args.severity,
audit_args.fail_on,
audit_args.source,
audit_args.sources.join(", "),
audit_args.scope_description(),
audit_args.direct_only
);
Expand Down
48 changes: 48 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ mod tests {
use super::*;
use std::fs;
use tempfile::TempDir;
use assert_cmd::Command;
use predicates::prelude::*;

#[test]
fn test_config_load_from_file() {
Expand Down Expand Up @@ -747,4 +749,50 @@ enabled = false
assert!(loader.config_path.is_none());
assert_eq!(loader.config.defaults.format, "human");
}

#[test]
fn test_display_sources_verbose_output() {
let temp_dir = TempDir::new().unwrap();
let config_path = temp_dir.path().join(".pysentry.toml");

// Default config without sources specified
let config_content = r#"
version = 1

[cache]
enabled = false

[output]
quiet = false
verbose = true
"#;
fs::write(&config_path, config_content).unwrap();

// Call the pysentry binary with the config file
// Only the default source "pypa" should be displayed
let mut cmd = Command::cargo_bin("pysentry").unwrap();
cmd.arg("--config").arg(config_path.to_str().unwrap());
cmd.assert()
.success()
.stderr(predicate::str::contains(", sources=[pypa],"));

// Add multiple sources to config and save file
let config_content = format!("{}\n{}",
config_content,
r#"

[sources]
enabled = ["pypa", "pypi", "osv"]
"#);

fs::write(&config_path, config_content).unwrap();

// Call the pysentry binary again with the updated config file
// Now all specified sources should be displayed
let mut cmd = Command::cargo_bin("pysentry").unwrap();
cmd.arg("--config").arg(config_path.to_str().unwrap());
cmd.assert()
.success()
.stderr(predicate::str::contains(", sources=[pypa, pypi, osv],"));
}
}