From: Vadim Anufriev Date: Tue, 21 Oct 2025 09:37:37 +0000 (+0400) Subject: test(pretty): add tests for pretty option X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.AggregateChangesetsError.html?a=commitdiff_plain;h=daebe537383ac17475ecbe6b9cdebc3a586ecb80;p=bdk-cli test(pretty): add tests for pretty option --- diff --git a/tests/cli_flags.rs b/tests/cli_flags.rs new file mode 100644 index 0000000..beec798 --- /dev/null +++ b/tests/cli_flags.rs @@ -0,0 +1,46 @@ +// Copyright (c) 2020-2025 Bitcoin Dev Kit Developers +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , 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::(&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()); +}