-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set tracing output to stderr and exit with non-zero code on error (#138)
Previously, the error was caught, printed, and ignored so the command always exits with a success (exit code `0`). * Add integration test for the URL command
- Loading branch information
Showing
5 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
mod common; | ||
|
||
use assert_cmd::Command; | ||
use common::create_config; | ||
use lair_keystore::dependencies::*; | ||
use std::{fs::File, io::Write}; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_url_command_only_outputs_connection_url() { | ||
let tmp_dir = tempdir::TempDir::new("lair keystore test").unwrap(); | ||
let passphrase = sodoken::BufRead::from(&b"passphrase"[..]); | ||
|
||
let config = create_config(&tmp_dir, passphrase.clone()).await; | ||
let config_path = tmp_dir.path().join("lair-keystore-config.yaml"); | ||
let mut config_file = | ||
File::create_new(config_path).expect("test config file already exists"); | ||
|
||
config_file | ||
.write_all(config.to_string().as_bytes()) | ||
.expect("failed to write config to file"); | ||
|
||
let mut cmd = Command::cargo_bin("lair-keystore").unwrap(); | ||
cmd.env("RUST_LOG", "trace"); // Enable all logging levels to make sure nothing gets printed to stdout | ||
cmd.arg(format!("--lair-root={}", tmp_dir.path().display())); | ||
cmd.arg("url"); | ||
|
||
let expected_stdout = format!("{}\n", config.connection_url); | ||
cmd.assert().success().stdout(expected_stdout); | ||
} |