Skip to content

Commit daebe53

Browse files
committed
test(pretty): add tests for pretty option
1 parent 17a4dca commit daebe53

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/cli_flags.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) 2020-2025 Bitcoin Dev Kit Developers
2+
//
3+
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
4+
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
6+
// You may not use this file except in accordance with one or both of these
7+
// licenses.
8+
9+
//! CLI Flags Tests
10+
//!
11+
//! Tests for global CLI flags and their behavior
12+
13+
use std::process::Command;
14+
15+
#[test]
16+
fn test_without_pretty_flag() {
17+
let output = Command::new("cargo")
18+
.args("run -- key generate".split_whitespace())
19+
.output()
20+
.unwrap();
21+
22+
assert!(output.status.success());
23+
24+
let stdout = String::from_utf8_lossy(&output.stdout);
25+
assert!(serde_json::from_str::<serde_json::Value>(&stdout).is_ok());
26+
}
27+
28+
#[test]
29+
fn test_pretty_flag_before_subcommand() {
30+
let output = Command::new("cargo")
31+
.args("run -- --pretty key generate".split_whitespace())
32+
.output()
33+
.unwrap();
34+
35+
assert!(output.status.success());
36+
}
37+
38+
#[test]
39+
fn test_pretty_flag_after_subcommand() {
40+
let output = Command::new("cargo")
41+
.args("run -- key generate --pretty".split_whitespace())
42+
.output()
43+
.unwrap();
44+
45+
assert!(output.status.success());
46+
}

0 commit comments

Comments
 (0)