ee1c6f3fcf
- Add a new argument, `--cli-version`, which the user can use to request a particular semver-compatible version of the CLI. - This enables breaking changes to the CLI, and enables `sq` to support multiple CLI versions. - Fixes #75.
43 lines
964 B
Rust
43 lines
964 B
Rust
use crate::integration::common::Sq;
|
|
|
|
/// Check that invalid syntax is caught.
|
|
#[test]
|
|
fn version() {
|
|
let sq = Sq::new();
|
|
|
|
let version = format!(
|
|
"{}.{}.{}",
|
|
env!("CARGO_PKG_VERSION_MAJOR"),
|
|
env!("CARGO_PKG_VERSION_MINOR"),
|
|
env!("CARGO_PKG_VERSION_PATCH"));
|
|
|
|
// Make sure "--cli-version" works.
|
|
let cmd = sq.command_args(&[
|
|
"--cli-version", &version,
|
|
"version"
|
|
][..]);
|
|
sq.run(cmd, true);
|
|
|
|
// Unsupported versions should be rejected.
|
|
let cmd = sq.command_args(&[
|
|
"--cli-version", "0.0.0",
|
|
"version"
|
|
]);
|
|
sq.run(cmd, false);
|
|
|
|
// --cli-version must be the first argument.
|
|
let cmd = sq.command_args(&[
|
|
"version",
|
|
"--cli-version", &version
|
|
]);
|
|
sq.run(cmd, false);
|
|
|
|
// Invalid versions should be rejected.
|
|
let cmd = sq.command_args(&[
|
|
"--cli-version", &version[1..],
|
|
"version"
|
|
]);
|
|
sq.run(cmd, false);
|
|
|
|
}
|