Skip to content

Commit

Permalink
Merge pull request #5 from No9/workflow-test
Browse files Browse the repository at this point in the history
Workflow test
  • Loading branch information
No9 authored Mar 6, 2024
2 parents 1cd430d + d282c63 commit 747d77b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,3 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- -D warnings

coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
args: '--ignore-tests --avoid-cfg-tarpaulin'
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libcrio"
version = "2.0.0"
version = "2.1.0"
edition = "2021"
authors = ["Anton Whalley <[email protected]>"]
description = "A wrapper around the crictl cli to return serde_json objects"
Expand Down
Empty file modified mock/big_data/crictl
100644 → 100755
Empty file.
38 changes: 17 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ impl Cli {
}
}
}
return Err(format!("no images matched in crictl img {:?}", log_args));
}
None => {
return Err(format!("no images found in crictl img {:?}", log_args));
Err(format!("no images matched in crictl img {:?}", log_args))
}
None => Err(format!("no images found in crictl img {:?}", log_args)),
}
}

Expand Down Expand Up @@ -327,12 +325,10 @@ impl Cli {
fn slice_to_value(slice: &[u8], args: Vec<&str>) -> Result<Value, String> {
match serde_json::from_slice(slice) {
Ok(v) => Ok(v),
Err(e) => {
return Err(format!(
"failed to create output from slice for {:?} {}",
args, e
));
}
Err(e) => Err(format!(
"failed to create output from slice for {:?} {}",
args, e
)),
}
}

Expand Down Expand Up @@ -383,12 +379,10 @@ fn run_command_text(args: Vec<&str>, bin_path: &str) -> Result<String, String> {
// }
let mut ok_str = String::new();
match waiter.stdout.as_slice().read_to_string(&mut ok_str) {
Err(e) => {
return Err(format!(
"stdout error - failed to execute crictl {:?} {}",
args, e
));
}
Err(e) => Err(format!(
"stdout error - failed to execute crictl {:?} {}",
args, e
)),
Ok(_) => Ok(ok_str),
}
}
Expand Down Expand Up @@ -599,7 +593,9 @@ mod tests {
fn test_inspect_container() {
for cli in get_clis() {
let val = cli
.inspect_container("765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7")
.inspect_container(
"765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7",
)
.unwrap();
assert_eq!(val["info"]["pid"].as_i64().unwrap(), 254405)
}
Expand All @@ -617,17 +613,17 @@ mod tests {
#[test]
fn test_inspect_container_only_errors_cli() {
let cli = get_only_errors_cli();
let val =
cli.inspect_container("765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7");
let val = cli
.inspect_container("765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7");
let expected = Err(String::from("failed to create output from slice for [\"inspect\", \"765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7\"] EOF while parsing a value at line 2 column 0"));
assert_eq!(expected, val);
}

#[test]
fn test_inspect_container_bad_json_cli() {
let cli = get_bad_json_cli();
let val =
cli.inspect_container("765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7");
let val = cli
.inspect_container("765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7");
let expected = Err(String::from("failed to create output from slice for [\"inspect\", \"765312810c818bca4836c3598e21471bfd96be8ca84ca952290a9900b7c055a7\"] EOF while parsing a value at line 2 column 0"));
assert_eq!(expected, val);
}
Expand Down

0 comments on commit 747d77b

Please sign in to comment.