use std::io::Write as _;
use assert_cmd::Command;
use assert_cmd::cargo::cargo_bin;
use predicates::str::contains;
use tempfile::{NamedTempFile, TempDir};
fn write_temp_manifest(content: &str) -> NamedTempFile {
let mut file = NamedTempFile::new().expect("temp manifest created");
file.write_all(content.as_bytes())
.expect("manifest written to temp file");
file
}
#[test]
#[ignore = "smoke: cross-OS CLI job"]
fn validate_and_export_run_without_docker() {
Command::new(cargo_bin("lightshuttle"))
.arg("--version")
.assert()
.success()
.stdout(contains("lightshuttle"));
let manifest = r#"
project:
name: ls-offline-smoke
resources:
app:
container:
image: alpine:3.20
command: ["sh", "-c", "sleep 1"]
"#;
let manifest_file = write_temp_manifest(manifest);
let path = manifest_file.path().to_str().expect("path is UTF-8");
Command::new(cargo_bin("lightshuttle"))
.args(["--file", path, "validate", "--strict"])
.assert()
.success();
let out = TempDir::new().expect("temp output dir created");
Command::new(cargo_bin("lightshuttle"))
.args(["--file", path, "export", "compose", "--output"])
.arg(out.path())
.assert()
.success();
let compose = out.path().join("docker-compose.yml");
assert!(
compose.is_file(),
"expected a compose file at {}",
compose.display(),
);
}