use tarpc::context;
use super::common::test_utils::setup_test_client;
use crate::{
commands::verify::verify_token_using_url,
constants::{ADDRESS, DEFAULT_ENVIRONMENT},
Result,
};
#[tokio::test]
async fn verify_token_rpc_error_mapping() -> Result<()> {
let client = setup_test_client(ADDRESS).await?;
let invalid_url = "https://invalid-url-that-does-not-exist";
let result = verify_token_using_url(invalid_url, client.to_owned()).await;
assert!(result.is_err());
let malformed_url = "not-a-url";
let result = verify_token_using_url(malformed_url, client).await;
assert!(result.is_err());
Ok(())
}
#[tokio::test]
async fn error_propagation_flow() -> Result<()> {
let client = setup_test_client(ADDRESS).await?;
let result = client
.create(
context::current(),
255, "TestToken".to_string(),
"TEST".to_string(),
"Description".to_string(),
false,
DEFAULT_ENVIRONMENT.to_string(),
)
.await?;
assert!(result.is_err());
let result = client
.create(
context::current(),
6,
"".to_string(), "TEST".to_string(),
"Description".to_string(),
false,
DEFAULT_ENVIRONMENT.to_string(),
)
.await?;
assert!(result.is_err());
let result = client
.create(
context::current(),
6,
"TestToken".to_string(),
"TEST".to_string(),
"Description".to_string(),
false,
"invalid_env".to_string(), )
.await?;
assert!(result.is_ok());
Ok(())
}