File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments