Skip to content

Make snapshot_version_format test robust to version changes #2

@daniloaguiarbr

Description

@daniloaguiarbr

Context

tests/snapshot_tests.rs::snapshot_version_format currently asserts the exact version string output by ssh-cli --version. The snapshot file tests/snapshots/snapshot_tests__version_format.snap must be manually updated on every release bump.

During v0.2.1 release (pin for elliptic-curve), this test failed because the snapshot expected ssh-cli 0.1.0 (HASH) but build produced ssh-cli 0.2.1 (HASH).

Proposal

Make the test redact the version string in addition to the hash:

// Current (line 62-70 of tests/snapshot_tests.rs)
let redacted = if let Some(start) = stdout.find('(') {
    if let Some(end) = stdout.find(')') {
        format!("{}(HASH){}", &stdout[..start], &stdout[end + 1..])
    } else {
        stdout
    }
} else {
    stdout
};

// Proposed: redact version too
// Regex: `ssh-cli <version> (<hash>)` -> `ssh-cli VERSION (HASH)`

Use regex or simple parse to replace the version number with VERSION placeholder. The snapshot would become stable across releases: ssh-cli VERSION (HASH).

Benefits

  • CI failures on version bump are eliminated.
  • Test focuses on the FORMAT of --version output, not the literal version.
  • Snapshot file becomes immutable between releases.

Priority

Low (quality-of-life). Current workaround: manually update snapshot on each release.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions