1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-10 17:46:15 +02:00

handle name as a str instead of a String in youki_integration_test.

This commit is contained in:
utam0k 2021-09-19 22:11:42 +09:00
parent aaebeaf614
commit 7b20c46efd
4 changed files with 33 additions and 30 deletions

View File

@ -12,6 +12,7 @@ members = [
]
exclude = [
"test_framework",
"youki_integration_test",
]
[features]

View File

@ -26,15 +26,15 @@ struct Opts {
}
// parse test string given in commandline option as pair of testgroup name and tests belonging to that
fn parse_tests(tests: &[String]) -> Vec<(String, Option<Vec<&str>>)> {
fn parse_tests(tests: &[String]) -> Vec<(&str, Option<Vec<&str>>)> {
let mut ret = Vec::with_capacity(tests.len());
for test in tests {
if test.contains("::") {
let (mod_name, test_names) = test.split_once("::").unwrap();
let _tests = test_names.split(',').collect();
ret.push((mod_name.to_owned(), Some(_tests)));
ret.push((mod_name, Some(_tests)));
} else {
ret.push((test.to_owned(), None));
ret.push((test, None));
}
}
ret

View File

@ -8,7 +8,7 @@ pub struct ContainerCreate {
container_id: String,
}
impl ContainerCreate {
impl<'a> ContainerCreate {
pub fn new(project_path: &Path) -> Self {
ContainerCreate {
project_path: project_path.to_owned(),
@ -53,24 +53,26 @@ impl ContainerCreate {
}
}
impl TestableGroup for ContainerCreate {
fn get_name(&self) -> String {
"create".to_owned()
impl<'a> TestableGroup<'a> for ContainerCreate {
fn get_name(&self) -> &'a str {
"create"
}
fn run_all(&self) -> Vec<(String, TestResult)> {
fn run_all(&self) -> Vec<(&'a str, TestResult)> {
vec![
("empty_id".to_owned(), self.create_empty_id()),
("valid_id".to_owned(), self.create_valid_id()),
("duplicate_id".to_owned(), self.create_duplicate_id()),
("empty_id", self.create_empty_id()),
("valid_id", self.create_valid_id()),
("duplicate_id", self.create_duplicate_id()),
]
}
fn run_selected(&self, selected: &[&str]) -> Vec<(String, TestResult)> {
fn run_selected(&self, selected: &[&str]) -> Vec<(&'a str, TestResult)> {
let mut ret = Vec::new();
for name in selected {
match *name {
"empty_id" => ret.push(("empty_id".to_owned(), self.create_empty_id())),
"valid_id" => ret.push(("valid_id".to_owned(), self.create_valid_id())),
"duplicate_id" => ret.push(("duplicate_id".to_owned(), self.create_duplicate_id())),
"empty_id" => ret.push(("empty_id", self.create_empty_id())),
"valid_id" => ret.push(("valid_id", self.create_valid_id())),
"duplicate_id" => ret.push(("duplicate_id", self.create_duplicate_id())),
_ => eprintln!("No test named {} in lifecycle", name),
};
}

View File

@ -39,28 +39,28 @@ impl ContainerLifecycle {
}
}
impl TestableGroup for ContainerLifecycle {
fn get_name(&self) -> String {
"lifecycle".to_owned()
impl<'a> TestableGroup<'a> for ContainerLifecycle {
fn get_name(&self) -> &'a str {
"lifecycle"
}
fn run_all(&self) -> Vec<(String, TestResult)> {
fn run_all(&self) -> Vec<(&'a str, TestResult)> {
vec![
("create".to_owned(), self.create()),
("start".to_owned(), self.start()),
("kill".to_owned(), self.kill()),
("state".to_owned(), self.state()),
("delete".to_owned(), self.delete()),
("create", self.create()),
("start", self.start()),
("kill", self.kill()),
("state", self.state()),
("delete", self.delete()),
]
}
fn run_selected(&self, selected: &[&str]) -> Vec<(String, TestResult)> {
fn run_selected(&self, selected: &[&str]) -> Vec<(&'a str, TestResult)> {
let mut ret = Vec::new();
for name in selected {
match *name {
"create" => ret.push(("create".to_owned(), self.create())),
"start" => ret.push(("start".to_owned(), self.start())),
"kill" => ret.push(("kill".to_owned(), self.kill())),
"state" => ret.push(("state".to_owned(), self.state())),
"delete" => ret.push(("delete".to_owned(), self.delete())),
"create" => ret.push(("create", self.create())),
"start" => ret.push(("start", self.start())),
"kill" => ret.push(("kill", self.kill())),
"state" => ret.push(("state", self.state())),
"delete" => ret.push(("delete", self.delete())),
_ => eprintln!("No test named {} in lifecycle", name),
};
}