mod common;
use std::process::{Command, Stdio};
use common::{Session, TempProject, ENTER, ESC};
#[test]
fn the_browser_navigates_to_a_detail_page_and_back_out() {
let project = TempProject::new("info-browse");
let mut session = Session::start(project.path(), &["info"]);
session.wait_for("What do you want to look up?");
session.send("Generated");
session.wait_for("Generated files");
session.send(ENTER);
session.wait_for("Generated files - what `rproj new` can write");
session.send("wally.toml");
session.wait_for("wally.toml - ");
session.send(ENTER);
session.wait_for("Settled, not asked, when you have:");
let screen = session.text();
for expected in [
"any package at all",
"the packages you picked are installed from it",
"the way to not have",
] {
assert!(screen.contains(expected), "expected {expected:?} in:\n{screen}");
}
session.send(ESC);
session.wait_for("What do you want to look up?");
session.send(ESC);
let outcome = session.finish();
assert_eq!(outcome.code, 0, "leaving the browser is a clean exit:\n{}", outcome.text);
}
#[test]
fn without_a_terminal_it_lists_instead_of_prompting() {
let output = Command::new(env!("CARGO_BIN_EXE_rproj"))
.arg("info")
.stdin(Stdio::null())
.output()
.expect("run rproj info");
assert_eq!(output.status.code(), Some(0));
let text = String::from_utf8_lossy(&output.stdout);
for expected in ["WALLY PACKAGES", "TOOLS", "GENERATED FILES", "TOPICS"] {
assert!(text.contains(expected), "expected {expected:?} in:\n{text}");
}
assert!(
!text.contains("What do you want to look up?"),
"must not try to prompt:\n{text}"
);
}
#[test]
fn a_named_lookup_prints_one_entry_and_exits() {
let output = Command::new(env!("CARGO_BIN_EXE_rproj"))
.args(["info", "rojo"])
.stdin(Stdio::null())
.output()
.expect("run rproj info rojo");
assert_eq!(output.status.code(), Some(0));
let text = String::from_utf8_lossy(&output.stdout);
assert!(text.starts_with("rojo\n----"), "{text}");
assert!(text.contains("rojo serve"), "the commands are the point:\n{text}");
assert!(!text.contains("WALLY PACKAGES"), "one entry, not the catalog:\n{text}");
}