Verified Commit eaf4d7c0 authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Add a test for multiple inputs

parent 3b672014
Pipeline #6831 passed with stages
in 2 minutes and 41 seconds
...@@ -308,3 +308,39 @@ pub fn dependency_cycle() -> (Vec<Package>, Option<String>, Vec<String>, TempDir ...@@ -308,3 +308,39 @@ pub fn dependency_cycle() -> (Vec<Package>, Option<String>, Vec<String>, TempDir
(packages, Some(dbpath), vec![reponame.to_string()], tempdir) (packages, Some(dbpath), vec![reponame.to_string()], tempdir)
} }
#[fixture]
pub fn multiple_pkgnames() -> (Vec<Package>, Option<String>, Vec<String>, TempDir) {
let testpkg = Package::new("testpkg1", "testpkg1", "1-1", vec![], vec![], vec![]);
let testpkg2 = Package::new(
"testpkg2",
"testpkg2",
"1-1",
vec![testpkg.name.clone()],
vec![],
vec![],
);
let testpkg3 = Package::new(
"testpkg3",
"testpkg3",
"1-1",
vec![testpkg.name.clone()],
vec![],
vec![],
);
let testpkg4 = Package::new(
"testpkg4",
"testpkg4",
"1-1",
vec![testpkg2.name.clone()],
vec![],
vec![],
);
let packages = vec![testpkg, testpkg2, testpkg3, testpkg4];
let reponame = "test";
let (tempdir, dbpath) = init_repodb(reponame.to_string(), packages.clone());
(packages, Some(dbpath), vec![reponame.to_string()], tempdir)
}
...@@ -4,8 +4,8 @@ use tempfile::TempDir; ...@@ -4,8 +4,8 @@ use tempfile::TempDir;
pub mod fixtures; pub mod fixtures;
use fixtures::{ use fixtures::{
dependency_cycle, dependency_depth, invalid_dbpath, multiple_deps, no_reverse_deps, dependency_cycle, dependency_depth, invalid_dbpath, multiple_deps, multiple_pkgnames,
provides_make_depends, reverse_deps, reverse_make_deps, Package, no_reverse_deps, provides_make_depends, reverse_deps, reverse_make_deps, Package,
}; };
#[rstest] #[rstest]
...@@ -142,3 +142,24 @@ fn test_dependency_cycle(dependency_cycle: (Vec<Package>, Option<String>, Vec<St ...@@ -142,3 +142,24 @@ fn test_dependency_cycle(dependency_cycle: (Vec<Package>, Option<String>, Vec<St
let res_pkgs: Vec<&str> = res.trim().split_ascii_whitespace().collect(); let res_pkgs: Vec<&str> = res.trim().split_ascii_whitespace().collect();
assert_eq!(packages[0], res_pkgs[0]); assert_eq!(packages[0], res_pkgs[0]);
} }
/// Given two packages names as input, with testpkg1 being a reverse dependency for testpkg2 and
/// testpkg3 and testpkg4 being a dependency of testpkg2. Providing "testpkg1 testpkg2" should
/// return "testpkg1 testpkg3 testpkg2 testpkg4"
#[rstest]
fn test_multiple_pkgnames(multiple_pkgnames: (Vec<Package>, Option<String>, Vec<String>, TempDir)) {
let packages = multiple_pkgnames.0;
let pkgname1 = &packages[0];
let pkgname2 = &packages[1];
let res = arch_rebuild_order::run(
vec![pkgname1.to_string(), pkgname2.to_string()],
multiple_pkgnames.1,
multiple_pkgnames.2,
None,
)
.unwrap();
let res_pkgs: Vec<&str> = res.trim().split_ascii_whitespace().collect();
let expected = vec!["testpkg1", "testpkg3", "testpkg2", "testpkg4"];
assert_eq!(res_pkgs, expected);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment