-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROVER-83 Add tests for
whoami
(#2022)
In this PR I've added a test for `whoami` and also consolidated some of the other 'integration-like' tests into the End-To-End test framework. This is pointing towards an eventual demarkation where we have end-to-end tests and more traditional integration tests sitting side by side but this is gradual process that we'll move towards over time.
- Loading branch information
1 parent
04d3b9c
commit f1d5abd
Showing
7 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
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,4 @@ | ||
mod auth; | ||
mod list; | ||
|
||
mod whoami; |
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,49 @@ | ||
use assert_cmd::Command; | ||
use rstest::rstest; | ||
use serde::Deserialize; | ||
use serde_json::Value; | ||
use speculoos::assert_that; | ||
use speculoos::prelude::BooleanAssertions; | ||
use tempfile::Builder; | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[allow(dead_code)] | ||
struct WhoAmIResponse { | ||
api_key: String, | ||
graph_id: Option<String>, | ||
graph_title: Option<String>, | ||
key_type: String, | ||
origin: String, | ||
success: bool, | ||
user_id: Option<String>, | ||
} | ||
|
||
#[rstest] | ||
#[ignore] | ||
fn e2e_test_rover_config_whoami() { | ||
let out_file = Builder::new() | ||
.suffix(".json") | ||
.tempfile() | ||
.expect("Could not create output file"); | ||
|
||
let mut cmd = Command::cargo_bin("rover").unwrap(); | ||
cmd.args([ | ||
"config", | ||
"whoami", | ||
"--format", | ||
"json", | ||
"--output", | ||
out_file.path().to_str().unwrap(), | ||
]) | ||
.assert() | ||
.success(); | ||
|
||
let response: Value = | ||
serde_json::from_reader(out_file.as_file()).expect("Cannot read JSON from response file"); | ||
// In deserializing the response, we're proving that sensitive details are present without | ||
// actually printing them | ||
let deserialised_response: WhoAmIResponse = | ||
serde_json::from_value(response["data"].clone()).unwrap(); | ||
// However we should assert on at least one just to double check that were' getting a sensible response | ||
assert_that!(deserialised_response.success).is_true(); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
use assert_cmd::Command; | ||
use predicates::prelude::*; | ||
|
||
mod config; | ||
mod dev; | ||
mod output; | ||
mod schema; | ||
|