39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
//! Integration tests for the `proctree` command.
|
|
|
|
use assert_cmd::Command;
|
|
use predicates::prelude::*;
|
|
|
|
fn cargo_command() -> Command {
|
|
Command::cargo_bin("proctree").expect("binary")
|
|
}
|
|
|
|
#[test]
|
|
fn reports_rooted_run_tree_as_json() {
|
|
let mut command = cargo_command();
|
|
command
|
|
.arg("run")
|
|
.arg("--json")
|
|
.arg("--")
|
|
.arg("pwsh")
|
|
.arg("-NoProfile")
|
|
.arg("-Command")
|
|
.arg("Start-Process pwsh -ArgumentList '-NoProfile','-Command','Start-Sleep -Milliseconds 800' -PassThru | Out-Null; Start-Sleep -Milliseconds 200")
|
|
.assert()
|
|
.success()
|
|
.stdout(predicate::str::contains("\"root_pid\""))
|
|
.stdout(predicate::str::contains("\"nodes\""))
|
|
.stdout(predicate::str::contains("\"image_name\":\"pwsh.exe\""));
|
|
}
|
|
|
|
#[test]
|
|
fn help_includes_proctree_examples() {
|
|
let mut command = cargo_command();
|
|
command
|
|
.arg("--help")
|
|
.assert()
|
|
.success()
|
|
.stdout(predicate::str::contains("system"))
|
|
.stdout(predicate::str::contains("root <PID>"))
|
|
.stdout(predicate::str::contains("ConvertFrom-Json"));
|
|
}
|