Skip to content

Commit b19d2ab

Browse files
authored
Integration tests (#26)
1 parent 9e4f0c3 commit b19d2ab

File tree

74 files changed

+438
-93885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+438
-93885
lines changed

.github/assets/demo/demo-dark.tape

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Set Width 1920
88
Set Height 750
99

1010
Hide
11-
Type "cd tests/test_end_to_end/test_default_use_case" Enter
11+
Type "cd tests/test_default_use_case" Enter
1212
Type "clear" Enter
1313

1414
Show

.github/assets/demo/demo-light.tape

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Set Width 2020
88
Set Height 750
99

1010
Hide
11-
Type "cd tests/test_end_to_end/test_default_use_case" Enter
11+
Type "cd tests/test_default_use_case" Enter
1212
Type "clear" Enter
1313

1414
Show

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
- uses: actions/checkout@v4
3737
- uses: Swatinem/rust-cache@f0deed1e0edfc6a9be95417288c0e1099b1eeec3
3838
- name: Run Clippy
39-
run: cargo clippy --all-targets --all-features -- -D clippy::all
39+
run: cargo clippy --all-targets --all-features -- -D clippy::all -A clippy::too_many_arguments

Cargo.lock

+48-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "conda-deny"
33
description = "A CLI tool to check your project's dependencies for license compliance."
4-
version = "0.3.3"
4+
version = "0.3.4"
55
edition = "2021"
66

77
[features]
@@ -35,6 +35,7 @@ anyhow = "1.0.95"
3535
clap-verbosity-flag = "3.0.2"
3636
env_logger = "0.11.6"
3737
log = "0.4.25"
38+
tempfile = "3.16.0"
3839

3940
[dev-dependencies]
4041
assert_cmd = "2.0.14"

src/cli.rs

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct Cli {
2222

2323
#[derive(clap::Subcommand, Debug)]
2424
pub enum CondaDenyCliConfig {
25+
/// Check licenses of pixi or conda environment against a whitelist
2526
Check {
2627
/// Path to the pixi lockfile(s)
2728
#[arg(short, long)]
@@ -47,6 +48,7 @@ pub enum CondaDenyCliConfig {
4748
#[arg(long, action = ArgAction::SetTrue)]
4849
ignore_pypi: Option<bool>,
4950
},
51+
/// List all packages and their licenses in your conda or pixi environment
5052
List {
5153
/// Path to the pixi lockfile(s)
5254
#[arg(short, long)]

src/conda_deny_config.rs

-71
Original file line numberDiff line numberDiff line change
@@ -149,74 +149,3 @@ impl CondaDenyTomlConfig {
149149
}
150150
}
151151
}
152-
153-
#[cfg(test)]
154-
mod tests {
155-
use std::vec;
156-
157-
use rstest::{fixture, rstest};
158-
159-
use super::*;
160-
161-
#[fixture]
162-
fn test_files() -> PathBuf {
163-
PathBuf::from("tests/test_pyproject_toml_files/")
164-
}
165-
166-
#[rstest]
167-
fn test_valid_config_multiple_urls(test_files: PathBuf) {
168-
let test_file_path = test_files.join("valid_config_multiple_urls.toml");
169-
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();
170-
171-
let license_config_paths = config.get_license_whitelists();
172-
assert_eq!(
173-
&license_config_paths,
174-
&vec![
175-
"https://example.org/conda-deny/base_config1.toml".to_string(),
176-
"https://example.org/conda-deny/base_config2.toml".to_string()
177-
]
178-
);
179-
}
180-
181-
#[rstest]
182-
fn test_missing_optional_fields(test_files: PathBuf) {
183-
let test_file_path = test_files.join("missing_optional_fields.toml");
184-
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();
185-
186-
let license_config_paths = config.get_license_whitelists();
187-
assert_eq!(
188-
license_config_paths,
189-
vec!("https://example.org/conda-deny/base_config.toml")
190-
);
191-
}
192-
193-
#[rstest]
194-
fn test_invalid_toml(test_files: PathBuf) {
195-
let test_file_path = test_files.join("invalid.toml");
196-
let result = CondaDenyTomlConfig::from_path(test_file_path);
197-
198-
assert!(result.is_err());
199-
}
200-
201-
#[rstest]
202-
fn test_get_license_config_paths(test_files: PathBuf) {
203-
let test_file_path = test_files.join("valid_config_single_url.toml");
204-
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();
205-
206-
assert_eq!(
207-
config.get_license_whitelists(),
208-
vec!["https://example.org/conda-deny/base_config.toml".to_string()]
209-
);
210-
211-
let test_file_path = test_files.join("valid_config_multiple_urls.toml");
212-
let config = CondaDenyTomlConfig::from_path(test_file_path).unwrap();
213-
214-
assert_eq!(
215-
config.get_license_whitelists(),
216-
vec![
217-
"https://example.org/conda-deny/base_config1.toml".to_string(),
218-
"https://example.org/conda-deny/base_config2.toml".to_string()
219-
]
220-
);
221-
}
222-
}

src/conda_meta_entry.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl CondaMetaEntry {
6363
}
6464
}
6565

66+
// TODO: Use rattler struct: PrefixRecord
6667
pub struct CondaMetaEntries {
6768
pub entries: Vec<CondaMetaEntry>,
6869
}

0 commit comments

Comments
 (0)