Skip to content

Commit 0e1d252

Browse files
committed
Add test for PURLs with trailing slash
Signed-off-by: Keshav Priyadarshi <[email protected]>
1 parent c00f243 commit 0e1d252

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ clean:
77
rm -rf target
88

99
test:
10-
cargo test
10+
cargo test -- --nocapture
1111

1212
valid:
1313
cargo fmt --all
@@ -17,4 +17,7 @@ check:
1717
cargo fmt --all -- --check
1818
cargo clippy --all-targets --all-features -- -D warnings
1919

20-
.PHONY: build-fst clean test valid check
20+
doc:
21+
cargo doc --open
22+
23+
.PHONY: build-fst clean test valid check doc

fst_builder/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ See https://aboutcode.org for more information about nexB OSS projects.
99
1010
*/
1111

12-
1312
use fst::SetBuilder;
1413
use std::fs::File;
1514
use std::io::{BufRead, BufReader};

src/validate_tests.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ See https://aboutcode.org for more information about nexB OSS projects.
99
1010
*/
1111

12-
1312
use super::*;
1413
use std::path::Path;
1514

@@ -18,6 +17,21 @@ fn test_validate_with_custom_file() {
1817
let test_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/test_purls.fst");
1918
let validator = load_fst(&test_path);
2019

20+
assert!(strip_and_check_purl(
21+
"pkg:nuget/FluentUtils.EnumExtensions",
22+
&validator
23+
));
24+
assert!(!strip_and_check_purl("pkg:example/nonexistent", &validator));
25+
}
26+
27+
#[test]
28+
fn test_validate_with_packageurl_trailing_slash() {
29+
let test_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/test_purls.fst");
30+
let validator = load_fst(&test_path);
31+
2132
assert!(validator.contains("pkg:nuget/FluentUtils.EnumExtensions"));
22-
assert!(!validator.contains("pkg:example/nonexistent"));
33+
assert!(strip_and_check_purl(
34+
"pkg:nuget/FluentUtils.EnumExtensions/",
35+
&validator
36+
));
2337
}

0 commit comments

Comments
 (0)