Skip to content

Commit

Permalink
arg install-upgrade bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gRoussac committed Oct 31, 2024
1 parent aef6def commit 2a50f2f
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/transaction/creation_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ pub(super) mod is_install_upgrade {
}

pub fn get(matches: &ArgMatches) -> bool {
matches.args_present()
matches.get_flag(ARG_NAME)
}
}

Expand Down Expand Up @@ -1964,3 +1964,36 @@ pub(super) fn parse_rpc_args_and_run(
verbosity_level,
))
}

#[cfg(test)]
mod tests {
use super::is_install_upgrade;
use clap::Command;

// Helper function to build a command with `is_install_upgrade` argument
fn build_app() -> Command {
Command::new("put-transaction session").arg(is_install_upgrade::arg(1))
}

#[test]
fn test_is_install_upgrade_flag_present() {
// Simulate running with the `--install-upgrade` flag
let matches = build_app()
.try_get_matches_from(vec!["put-transaction session", "--install-upgrade"])
.unwrap();

// Assert that `get` returns true when the flag is present
assert!(is_install_upgrade::get(&matches));
}

#[test]
fn test_is_install_upgrade_flag_absent() {
// Simulate running without the `--install-upgrade` flag
let matches = build_app()
.try_get_matches_from(vec!["put-transaction session"])
.unwrap();

// Assert that `get` returns false when the flag is absent
assert!(!is_install_upgrade::get(&matches));
}
}

0 comments on commit 2a50f2f

Please sign in to comment.