]> Untitled Git - bdk-cli/commitdiff
test(pretty): add tests for pretty option
authorVadim Anufriev <mailbox@vaan.io>
Tue, 21 Oct 2025 09:37:37 +0000 (13:37 +0400)
committerVadim Anufriev <mailbox@vaan.io>
Tue, 21 Oct 2025 09:37:37 +0000 (13:37 +0400)
tests/cli_flags.rs [new file with mode: 0644]

diff --git a/tests/cli_flags.rs b/tests/cli_flags.rs
new file mode 100644 (file)
index 0000000..beec798
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (c) 2020-2025 Bitcoin Dev Kit Developers
+//
+// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE
+// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option.
+// You may not use this file except in accordance with one or both of these
+// licenses.
+
+//! CLI Flags Tests
+//!
+//! Tests for global CLI flags and their behavior
+
+use std::process::Command;
+
+#[test]
+fn test_without_pretty_flag() {
+    let output = Command::new("cargo")
+        .args("run -- key generate".split_whitespace())
+        .output()
+        .unwrap();
+
+    assert!(output.status.success());
+
+    let stdout = String::from_utf8_lossy(&output.stdout);
+    assert!(serde_json::from_str::<serde_json::Value>(&stdout).is_ok());
+}
+
+#[test]
+fn test_pretty_flag_before_subcommand() {
+    let output = Command::new("cargo")
+        .args("run -- --pretty key generate".split_whitespace())
+        .output()
+        .unwrap();
+
+    assert!(output.status.success());
+}
+
+#[test]
+fn test_pretty_flag_after_subcommand() {
+    let output = Command::new("cargo")
+        .args("run -- key generate --pretty".split_whitespace())
+        .output()
+        .unwrap();
+
+    assert!(output.status.success());
+}