diff --git a/Cargo.lock b/Cargo.lock index f2cde346ab..ff572c6d77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1786,7 +1786,6 @@ version = "1.0.0" dependencies = [ "anyhow", "camino", - "scarb-metadata", "serde", "serde_json", "tempfile", diff --git a/crates/configuration/Cargo.toml b/crates/configuration/Cargo.toml index 8ecdb1cd16..3cd084799d 100644 --- a/crates/configuration/Cargo.toml +++ b/crates/configuration/Cargo.toml @@ -13,5 +13,3 @@ serde.workspace = true camino.workspace = true toml.workspace = true tempfile.workspace = true -scarb-metadata.workspace = true - diff --git a/crates/configuration/src/core.rs b/crates/configuration/src/core.rs new file mode 100644 index 0000000000..1467c9dcfc --- /dev/null +++ b/crates/configuration/src/core.rs @@ -0,0 +1,83 @@ +use crate::Config; +use anyhow::anyhow; +use serde_json::Number; +use std::env; + +fn resolve_env_variables(config: serde_json::Value) -> anyhow::Result { + match config { + serde_json::Value::Object(map) => { + let val = map + .into_iter() + .map(|(k, v)| -> anyhow::Result<(String, serde_json::Value)> { + Ok((k, resolve_env_variables(v)?)) + }) + .collect::>>()?; + Ok(serde_json::Value::Object(val)) + } + serde_json::Value::Array(val) => { + let val = val + .into_iter() + .map(resolve_env_variables) + .collect::>>()?; + Ok(serde_json::Value::Array(val)) + } + serde_json::Value::String(val) if val.starts_with('$') => resolve_env_variable(&val), + val => Ok(val), + } +} + +fn resolve_env_variable(var: &str) -> anyhow::Result { + assert!(var.starts_with('$')); + let mut initial_value = &var[1..]; + if initial_value.starts_with('{') && initial_value.ends_with('}') { + initial_value = &initial_value[1..initial_value.len() - 1]; + } + let value = env::var(initial_value)?; + + if let Ok(value) = value.parse::() { + return Ok(serde_json::Value::Number(value)); + } + if let Ok(value) = value.parse::() { + return Ok(serde_json::Value::Bool(value)); + } + Ok(serde_json::Value::String(value)) +} + +fn get_with_ownership(config: serde_json::Value, key: &str) -> Option { + match config { + serde_json::Value::Object(mut map) => map.remove(key), + _ => None, + } +} + +fn get_profile( + raw_config: serde_json::Value, + tool: &str, + profile: &str, +) -> Option { + let profile_name = profile; + let tool_config = get_with_ownership(raw_config, tool) + .unwrap_or(serde_json::Value::Object(serde_json::Map::new())); + + get_with_ownership(tool_config, profile_name) +} + +pub enum Profile { + None, + Default, + Some(String), +} + +pub fn load_config( + raw_config: serde_json::Value, + profile: Profile, +) -> anyhow::Result { + let raw_config_json = match profile { + Profile::None => raw_config, + Profile::Default => get_profile(raw_config, T::tool_name(), "default") + .unwrap_or_else(|| serde_json::Value::Object(serde_json::Map::new())), + Profile::Some(profile) => get_profile(raw_config, T::tool_name(), &profile) + .ok_or_else(|| anyhow!("Profile [{profile}] not found in config"))?, + }; + T::from_raw(resolve_env_variables(raw_config_json)?) +} diff --git a/crates/configuration/src/lib.rs b/crates/configuration/src/lib.rs index dd553fc2e8..32e85d65eb 100644 --- a/crates/configuration/src/lib.rs +++ b/crates/configuration/src/lib.rs @@ -1,14 +1,15 @@ +use crate::core::Profile; use anyhow::{Context, Result, anyhow}; use camino::Utf8PathBuf; -use scarb_metadata::{Metadata, PackageId}; -use serde_json::{Map, Number}; use std::fs::File; use std::{env, fs}; -use tempfile::{TempDir, tempdir}; use toml::Value; + +pub mod core; +pub mod test_utils; + pub const CONFIG_FILENAME: &str = "snfoundry.toml"; -/// Defined in snfoundry.toml /// Configuration not associated with any specific package pub trait Config { #[must_use] @@ -19,40 +20,6 @@ pub trait Config { Self: Sized; } -/// Defined in scarb manifest -/// Configuration associated with a specific package -pub trait PackageConfig { - #[must_use] - fn tool_name() -> &'static str; - - fn from_raw(config: &serde_json::Value) -> Result - where - Self: Sized; -} - -fn get_with_ownership(config: serde_json::Value, key: &str) -> Option { - match config { - serde_json::Value::Object(mut map) => map.remove(key), - _ => None, - } -} - -pub fn get_profile( - raw_config: serde_json::Value, - tool: &str, - profile: Option<&str>, -) -> Result { - let profile_name = profile.unwrap_or("default"); - let tool_config = get_with_ownership(raw_config, tool) - .unwrap_or(serde_json::Value::Object(serde_json::Map::new())); - - match get_with_ownership(tool_config, profile_name) { - Some(profile_value) => Ok(profile_value), - None if profile_name == "default" => Ok(serde_json::Value::Object(Map::default())), - None => Err(anyhow!("Profile [{profile_name}] not found in config")), - } -} - #[must_use] pub fn resolve_config_file() -> Utf8PathBuf { find_config_file().unwrap_or_else(|_| { @@ -83,70 +50,14 @@ pub fn load_config( let raw_config_json = serde_json::to_value(raw_config_toml) .context("Conversion from TOML value to JSON value should not fail.")?; - let profile = get_profile(raw_config_json, T::tool_name(), profile)?; - T::from_raw(resolve_env_variables(profile)?) + core::load_config( + raw_config_json, + profile.map_or_else(|| Profile::Default, |p| Profile::Some(p.to_string())), + ) } None => Ok(T::default()), } } -/// Loads config for a specific package from the `Scarb.toml` file -/// # Arguments -/// * `metadata` - Scarb metadata object -/// * `package` - Id of the Scarb package -pub fn load_package_config( - metadata: &Metadata, - package: &PackageId, -) -> Result { - let maybe_raw_metadata = metadata - .get_package(package) - .ok_or_else(|| anyhow!("Failed to find metadata for package = {package}"))? - .tool_metadata(T::tool_name()) - .cloned(); - match maybe_raw_metadata { - Some(raw_metadata) => T::from_raw(&resolve_env_variables(raw_metadata)?), - None => Ok(T::default()), - } -} - -fn resolve_env_variables(config: serde_json::Value) -> Result { - match config { - serde_json::Value::Object(map) => { - let val = map - .into_iter() - .map(|(k, v)| -> Result<(String, serde_json::Value)> { - Ok((k, resolve_env_variables(v)?)) - }) - .collect::>>()?; - Ok(serde_json::Value::Object(val)) - } - serde_json::Value::Array(val) => { - let val = val - .into_iter() - .map(resolve_env_variables) - .collect::>>()?; - Ok(serde_json::Value::Array(val)) - } - serde_json::Value::String(val) if val.starts_with('$') => resolve_env_variable(&val), - val => Ok(val), - } -} - -fn resolve_env_variable(var: &str) -> Result { - assert!(var.starts_with('$')); - let mut initial_value = &var[1..]; - if initial_value.starts_with('{') && initial_value.ends_with('}') { - initial_value = &initial_value[1..initial_value.len() - 1]; - } - let value = env::var(initial_value)?; - - if let Ok(value) = value.parse::() { - return Ok(serde_json::Value::Number(value)); - } - if let Ok(value) = value.parse::() { - return Ok(serde_json::Value::Bool(value)); - } - Ok(serde_json::Value::String(value)) -} pub fn search_config_upwards_relative_to(current_dir: &Utf8PathBuf) -> Result { current_dir @@ -166,30 +77,18 @@ pub fn find_config_file() -> Result { )?) } -pub fn copy_config_to_tempdir(src_path: &str, additional_path: Option<&str>) -> Result { - let temp_dir = tempdir().context("Failed to create a temporary directory")?; - if let Some(dir) = additional_path { - let path = temp_dir.path().join(dir); - fs::create_dir_all(path).context("Failed to create directories in temp dir")?; - } - let temp_dir_file_path = temp_dir.path().join(CONFIG_FILENAME); - fs::copy(src_path, temp_dir_file_path).context("Failed to copy config file to temp dir")?; - - Ok(temp_dir) -} - #[cfg(test)] mod tests { use std::fs::{self, File}; + use super::*; + use crate::test_utils::copy_config_to_tempdir; use serde::{Deserialize, Serialize}; use tempfile::tempdir; - use super::*; - #[test] fn find_config_in_current_dir() { - let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None); let path = search_config_upwards_relative_to( &Utf8PathBuf::try_from(tempdir.path().to_path_buf()).unwrap(), ) @@ -200,7 +99,7 @@ mod tests { #[test] fn find_config_in_parent_dir() { let tempdir = - copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir")).unwrap(); + copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir")); let path = search_config_upwards_relative_to( &Utf8PathBuf::try_from(tempdir.path().to_path_buf().join("childdir")).unwrap(), ) @@ -213,8 +112,7 @@ mod tests { let tempdir = copy_config_to_tempdir( "tests/data/stubtool_snfoundry.toml", Some("childdir1/childdir2"), - ) - .unwrap(); + ); let path = search_config_upwards_relative_to( &Utf8PathBuf::try_from(tempdir.path().to_path_buf().join("childdir1/childdir2")) .unwrap(), @@ -226,8 +124,7 @@ mod tests { #[test] fn find_config_in_parent_dir_available_in_multiple_parents() { let tempdir = - copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir1")) - .unwrap(); + copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir1")); fs::copy( "tests/data/stubtool_snfoundry.toml", tempdir.path().join("childdir1").join(CONFIG_FILENAME), @@ -270,7 +167,7 @@ mod tests { } #[test] fn load_config_happy_case_with_profile() { - let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None); let config = load_config::( Some(&Utf8PathBuf::try_from(tempdir.path().to_path_buf()).unwrap()), Some(&String::from("profile1")), @@ -282,7 +179,7 @@ mod tests { #[test] fn load_config_happy_case_default_profile() { - let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", None); let config = load_config::( Some(&Utf8PathBuf::try_from(tempdir.path().to_path_buf()).unwrap()), None, @@ -354,8 +251,7 @@ mod tests { #[expect(clippy::float_cmp)] fn resolve_env_vars() { let tempdir = - copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir1")) - .unwrap(); + copy_config_to_tempdir("tests/data/stubtool_snfoundry.toml", Some("childdir1")); fs::copy( "tests/data/stubtool_snfoundry.toml", tempdir.path().join("childdir1").join(CONFIG_FILENAME), diff --git a/crates/configuration/src/test_utils.rs b/crates/configuration/src/test_utils.rs new file mode 100644 index 0000000000..f79c9a7016 --- /dev/null +++ b/crates/configuration/src/test_utils.rs @@ -0,0 +1,16 @@ +use crate::CONFIG_FILENAME; +use std::fs; +use tempfile::{TempDir, tempdir}; + +#[must_use] +pub fn copy_config_to_tempdir(src_path: &str, additional_path: Option<&str>) -> TempDir { + let temp_dir = tempdir().expect("Failed to create a temporary directory"); + if let Some(dir) = additional_path { + let path = temp_dir.path().join(dir); + fs::create_dir_all(path).expect("Failed to create directories in temp dir"); + } + let temp_dir_file_path = temp_dir.path().join(CONFIG_FILENAME); + fs::copy(src_path, temp_dir_file_path).expect("Failed to copy config file to temp dir"); + + temp_dir +} diff --git a/crates/forge/src/run_tests/package.rs b/crates/forge/src/run_tests/package.rs index 1f565927fc..c01523d2cc 100644 --- a/crates/forge/src/run_tests/package.rs +++ b/crates/forge/src/run_tests/package.rs @@ -2,6 +2,7 @@ use super::{ resolve_config::resolve_config, test_target::{TestTargetRunResult, run_for_test_target}, }; +use crate::scarb::load_package_config; use crate::{ TestArgs, block_number_map::BlockNumberMap, @@ -24,7 +25,6 @@ use crate::{ use anyhow::Result; use camino::{Utf8Path, Utf8PathBuf}; use cheatnet::runtime_extensions::forge_runtime_extension::contracts_data::ContractsData; -use configuration::load_package_config; use console::Style; use forge_runner::{ forge_config::ForgeConfig, diff --git a/crates/forge/src/scarb.rs b/crates/forge/src/scarb.rs index 2723d3060d..10f28aa6bc 100644 --- a/crates/forge/src/scarb.rs +++ b/crates/forge/src/scarb.rs @@ -1,12 +1,13 @@ use crate::scarb::config::ForgeConfigFromScarb; -use anyhow::{Context, Result}; +use anyhow::{Context, Result, anyhow}; use cairo_lang_sierra::program::VersionedProgram; use camino::Utf8Path; -use configuration::PackageConfig; +use configuration::Config; +use configuration::core::Profile; use forge_runner::package_tests::TestTargetLocation; use forge_runner::package_tests::raw::TestTargetRaw; use scarb_api::{ScarbCommand, test_targets_by_name}; -use scarb_metadata::PackageMetadata; +use scarb_metadata::{Metadata, PackageId, PackageMetadata}; use scarb_ui::args::{FeaturesSpec, PackagesFilter, ProfileSpec}; use semver::Version; use std::fs; @@ -16,12 +17,12 @@ pub mod config; const MINIMAL_SCARB_VERSION_TO_OPTIMIZE_COMPILATION: Version = Version::new(2, 8, 3); -impl PackageConfig for ForgeConfigFromScarb { +impl Config for ForgeConfigFromScarb { fn tool_name() -> &'static str { "snforge" } - fn from_raw(config: &serde_json::Value) -> Result + fn from_raw(config: serde_json::Value) -> Result where Self: Sized, { @@ -29,6 +30,26 @@ impl PackageConfig for ForgeConfigFromScarb { } } +/// Loads config for a specific package from the `Scarb.toml` file +/// # Arguments +/// * `metadata` - Scarb metadata object +/// * `package` - Id of the Scarb package +pub fn load_package_config( + metadata: &Metadata, + package: &PackageId, +) -> Result { + let maybe_raw_metadata = metadata + .get_package(package) + .ok_or_else(|| anyhow!("Failed to find metadata for package = {package}"))? + .tool_metadata(T::tool_name()) + .cloned(); + + match maybe_raw_metadata { + Some(raw_metadata) => configuration::core::load_config(raw_metadata, Profile::None), + None => Ok(T::default()), + } +} + #[must_use] pub fn should_compile_starknet_contract_target( scarb_version: &Version, diff --git a/crates/forge/tests/integration/mod.rs b/crates/forge/tests/integration/mod.rs index f86eae4af6..a89e5fa30b 100644 --- a/crates/forge/tests/integration/mod.rs +++ b/crates/forge/tests/integration/mod.rs @@ -7,6 +7,7 @@ mod cheat_caller_address; mod cheat_execution_info; mod cheat_fork; mod cheat_sequencer_address; +mod config; mod declare; mod deploy; mod deploy_at; diff --git a/crates/sncast/src/starknet_commands/account/mod.rs b/crates/sncast/src/starknet_commands/account/mod.rs index d011bbb808..b591824644 100644 --- a/crates/sncast/src/starknet_commands/account/mod.rs +++ b/crates/sncast/src/starknet_commands/account/mod.rs @@ -335,7 +335,7 @@ pub async fn account( #[cfg(test)] mod tests { use camino::Utf8PathBuf; - use configuration::copy_config_to_tempdir; + use configuration::test_utils::copy_config_to_tempdir; use sncast::helpers::configuration::CastConfig; use sncast::helpers::constants::DEFAULT_ACCOUNTS_FILE; use std::fs; @@ -344,8 +344,7 @@ mod tests { #[test] fn test_add_created_profile_to_configuration_happy_case() { - let tempdir = - copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let path = Utf8PathBuf::try_from(tempdir.path().to_path_buf()).unwrap(); let config = CastConfig { url: String::from("http://some-url"), @@ -370,8 +369,7 @@ mod tests { #[test] fn test_add_created_profile_to_configuration_profile_already_exists() { - let tempdir = - copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let config = CastConfig { url: String::from("http://127.0.0.1:5055/rpc"), account: String::from("user1"), diff --git a/crates/sncast/tests/e2e/account/create.rs b/crates/sncast/tests/e2e/account/create.rs index af135dd365..0d3cc53ce3 100644 --- a/crates/sncast/tests/e2e/account/create.rs +++ b/crates/sncast/tests/e2e/account/create.rs @@ -1,7 +1,7 @@ use crate::helpers::constants::{ACCOUNT_FILE_PATH, DEVNET_OZ_CLASS_HASH_CAIRO_0, URL}; use crate::helpers::fixtures::copy_file; use crate::helpers::runner::runner; -use configuration::copy_config_to_tempdir; +use configuration::test_utils::copy_config_to_tempdir; use indoc::{formatdoc, indoc}; use crate::helpers::env::set_create_keystore_password_env; @@ -354,7 +354,7 @@ pub async fn test_add_profile_with_network() { #[tokio::test] pub async fn test_profile_already_exists() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let accounts_file = "accounts.json"; let args = vec![ @@ -515,7 +515,7 @@ pub async fn test_happy_case_keystore_argent_with_deprecation_warning() { #[tokio::test] pub async fn test_happy_case_keystore_add_profile() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let keystore_file = "my_key.json"; let account_file = "my_account.json"; let accounts_json_file = "accounts.json"; diff --git a/crates/sncast/tests/e2e/account/deploy.rs b/crates/sncast/tests/e2e/account/deploy.rs index 1e3938665c..f36ed85274 100644 --- a/crates/sncast/tests/e2e/account/deploy.rs +++ b/crates/sncast/tests/e2e/account/deploy.rs @@ -7,7 +7,7 @@ use crate::helpers::fixtures::{ }; use crate::helpers::runner::runner; use camino::Utf8PathBuf; -use configuration::copy_config_to_tempdir; +use configuration::test_utils::copy_config_to_tempdir; use conversions::string::IntoHexStr; use indoc::indoc; use shared::test_utils::output_assert::{AsOutput, assert_stderr_contains}; @@ -224,7 +224,7 @@ pub async fn test_valid_no_max_fee() { } pub async fn create_account(add_profile: bool, class_hash: &str, account_type: &str) -> TempDir { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let accounts_file = "accounts.json"; let mut args = vec![ diff --git a/crates/sncast/tests/e2e/main_tests.rs b/crates/sncast/tests/e2e/main_tests.rs index c3ccf50f9e..cedf9d17c4 100644 --- a/crates/sncast/tests/e2e/main_tests.rs +++ b/crates/sncast/tests/e2e/main_tests.rs @@ -7,13 +7,13 @@ use crate::helpers::fixtures::{ duplicate_contract_directory_with_salt, get_accounts_path, get_keystores_path, }; use crate::helpers::runner::runner; -use configuration::copy_config_to_tempdir; +use configuration::test_utils::copy_config_to_tempdir; use indoc::indoc; use shared::test_utils::output_assert::assert_stderr_contains; #[tokio::test] async fn test_happy_case_from_sncast_config() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, @@ -37,7 +37,7 @@ async fn test_happy_case_from_sncast_config() { #[tokio::test] async fn test_happy_case_predefined_network() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, @@ -63,7 +63,7 @@ async fn test_happy_case_predefined_network() { #[tokio::test] async fn test_url_with_network_args() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, @@ -91,7 +91,7 @@ async fn test_url_with_network_args() { #[tokio::test] async fn test_network_with_url_defined_in_config_toml() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, @@ -142,7 +142,7 @@ async fn test_happy_case_from_cli_no_scarb() { #[tokio::test] async fn test_happy_case_from_cli_with_sncast_config() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, @@ -175,7 +175,7 @@ async fn test_happy_case_from_cli_with_sncast_config() { #[tokio::test] async fn test_happy_case_mixed() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec![ "--accounts-file", ACCOUNT_FILE_PATH, diff --git a/crates/sncast/tests/e2e/show_config.rs b/crates/sncast/tests/e2e/show_config.rs index e3ce440dc6..bfe54d4383 100644 --- a/crates/sncast/tests/e2e/show_config.rs +++ b/crates/sncast/tests/e2e/show_config.rs @@ -1,10 +1,10 @@ use crate::helpers::{constants::URL, runner::runner}; -use configuration::copy_config_to_tempdir; +use configuration::test_utils::copy_config_to_tempdir; use indoc::formatdoc; #[tokio::test] async fn test_show_config_from_snfoundry_toml() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec!["show-config"]; let snapbox = runner(&args).current_dir(tempdir.path()); @@ -51,7 +51,7 @@ async fn test_show_config_from_cli() { #[tokio::test] async fn test_show_config_from_cli_and_snfoundry_toml() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec!["--account", "user2", "--profile", "profile2", "show-config"]; let snapbox = runner(&args).current_dir(tempdir.path()); @@ -70,7 +70,7 @@ async fn test_show_config_from_cli_and_snfoundry_toml() { #[tokio::test] async fn test_show_config_when_no_keystore() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec!["--profile", "profile4", "show-config"]; let snapbox = runner(&args).current_dir(tempdir.path()); @@ -89,7 +89,7 @@ async fn test_show_config_when_no_keystore() { #[tokio::test] async fn test_show_config_when_keystore() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec!["--profile", "profile3", "show-config"]; let snapbox = runner(&args).current_dir(tempdir.path()); @@ -108,7 +108,7 @@ async fn test_show_config_when_keystore() { #[tokio::test] async fn test_show_config_no_url() { - let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None).unwrap(); + let tempdir = copy_config_to_tempdir("tests/data/files/correct_snfoundry.toml", None); let args = vec!["--profile", "profile6", "show-config"]; let snapbox = runner(&args).current_dir(tempdir.path());