Skip to content

Commit

Permalink
Merge pull request #41 from alexwlchan/test-version
Browse files Browse the repository at this point in the history
Add a test for the `--version` flag
  • Loading branch information
alexwlchan authored Jun 17, 2024
2 parents 9f32e5e + a58de6e commit d0b8a83
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
assert_cmd = "2.0.14"
clap = "4.5.7"
regex = "1.10.5"

[dependencies.kmeans_colors]
version = "0.6.0"
Expand Down
13 changes: 13 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod tests {

use assert_cmd::assert::OutputAssertExt;
use assert_cmd::Command;
use regex::Regex;

// Note: for the purposes of these tests, I mostly trust the k-means code
// provided by the external library.
Expand Down Expand Up @@ -245,6 +246,18 @@ mod tests {
assert_eq!(output.stdout, "#693900\n");
}

#[test]
fn it_prints_the_version() {
let output = get_success(&["--version"]);

let re = Regex::new(r"^dominant_colours [0-9]+\.[0-9]+\.[0-9]+\n$").unwrap();

assert!(re.is_match(&output.stdout));

assert_eq!(output.exit_code, 0);
assert_eq!(output.stderr, "");
}

struct DcOutput {
exit_code: i32,
stdout: String,
Expand Down

0 comments on commit d0b8a83

Please sign in to comment.