Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #26

Merged
merged 20 commits into from
Feb 12, 2025
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
2 changes: 1 addition & 1 deletion .github/assets/demo/demo-dark.tape
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Set Width 1920
Set Height 750

Hide
Type "cd tests/test_end_to_end/test_default_use_case" Enter
Type "cd tests/test_default_use_case" Enter
Type "clear" Enter

Show
Expand Down
2 changes: 1 addition & 1 deletion .github/assets/demo/demo-light.tape
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Set Width 2020
Set Height 750

Hide
Type "cd tests/test_end_to_end/test_default_use_case" Enter
Type "cd tests/test_default_use_case" Enter
Type "clear" Enter

Show
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3
- name: Run Clippy
run: cargo clippy --all-targets --all-features -- -D clippy::all
run: cargo clippy --all-targets --all-features -- -D clippy::all -A clippy::too_many_arguments
64 changes: 48 additions & 16 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "conda-deny"
description = "A CLI tool to check your project's dependencies for license compliance."
version = "0.3.3"
version = "0.3.4"
edition = "2021"

[features]
Expand Down Expand Up @@ -35,6 +35,7 @@ anyhow = "1.0.95"
clap-verbosity-flag = "3.0.2"
env_logger = "0.11.6"
log = "0.4.25"
tempfile = "3.16.0"

[dev-dependencies]
assert_cmd = "2.0.14"
Expand Down
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Cli {

#[derive(clap::Subcommand, Debug)]
pub enum CondaDenyCliConfig {
/// Check licenses of pixi or conda environment against a whitelist
Check {
/// Path to the pixi lockfile(s)
#[arg(short, long)]
Expand All @@ -47,6 +48,7 @@ pub enum CondaDenyCliConfig {
#[arg(long, action = ArgAction::SetTrue)]
ignore_pypi: Option<bool>,
},
/// List all packages and their licenses in your conda or pixi environment
List {
/// Path to the pixi lockfile(s)
#[arg(short, long)]
Expand Down
71 changes: 0 additions & 71 deletions src/conda_deny_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,74 +149,3 @@ impl CondaDenyTomlConfig {
}
}
}

#[cfg(test)]
mod tests {
use std::vec;

use rstest::{fixture, rstest};

use super::*;

#[fixture]
fn test_files() -> PathBuf {
PathBuf::from("tests/test_pyproject_toml_files/")
}

#[rstest]
fn test_valid_config_multiple_urls(test_files: PathBuf) {
let test_file_path = test_files.join("valid_config_multiple_urls.toml");
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();

let license_config_paths = config.get_license_whitelists();
assert_eq!(
&license_config_paths,
&vec![
"https://example.org/conda-deny/base_config1.toml".to_string(),
"https://example.org/conda-deny/base_config2.toml".to_string()
]
);
}

#[rstest]
fn test_missing_optional_fields(test_files: PathBuf) {
let test_file_path = test_files.join("missing_optional_fields.toml");
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();

let license_config_paths = config.get_license_whitelists();
assert_eq!(
license_config_paths,
vec!("https://example.org/conda-deny/base_config.toml")
);
}

#[rstest]
fn test_invalid_toml(test_files: PathBuf) {
let test_file_path = test_files.join("invalid.toml");
let result = CondaDenyTomlConfig::from_path(test_file_path);

assert!(result.is_err());
}

#[rstest]
fn test_get_license_config_paths(test_files: PathBuf) {
let test_file_path = test_files.join("valid_config_single_url.toml");
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();

assert_eq!(
config.get_license_whitelists(),
vec!["https://example.org/conda-deny/base_config.toml".to_string()]
);

let test_file_path = test_files.join("valid_config_multiple_urls.toml");
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();

assert_eq!(
config.get_license_whitelists(),
vec![
"https://example.org/conda-deny/base_config1.toml".to_string(),
"https://example.org/conda-deny/base_config2.toml".to_string()
]
);
}
}
1 change: 1 addition & 0 deletions src/conda_meta_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl CondaMetaEntry {
}
}

// TODO: Use rattler struct: PrefixRecord
pub struct CondaMetaEntries {
pub entries: Vec<CondaMetaEntry>,
}
Expand Down
Loading