Skip to content

Commit

Permalink
Fix version number tests (#690)
Browse files Browse the repository at this point in the history
Use a regex recommended by semver.org to verify the cli version output. The change allows tests to pass even on dirty Git repos, where version includes the "-dirty" indicator introduced in #678).

Signed-off-by: Alessandro Passaro <[email protected]>
  • Loading branch information
passaro authored Jan 5, 2024
1 parent f4b420b commit 024a7f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mountpoint-s3/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use predicates::prelude::*; // Used for writing assertions
use std::{fs, os::unix::prelude::PermissionsExt, process::Command}; // Run programs

/// Regular expression for something that looks mostly like a SemVer version.
/// Don't use this outside of this test - SemVer is both more restrictive and flexible.
const VALID_VERSION_OUTPUT_PATTERN: &str = "^mount-s3 \\d+\\.\\d+\\.\\d+(?:-\\w+(?:\\.\\w+)*)*(?:\\+[\\w\\.]+)*\n$";
/// See https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string.
const VALID_VERSION_OUTPUT_PATTERN: &str = "^mount-s3 (0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?\n$";

#[test]
fn mount_point_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
Expand Down

0 comments on commit 024a7f4

Please sign in to comment.