Skip to content

Commit

Permalink
fixup! WIP: needs refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
steveej committed Nov 7, 2024
1 parent a9cba70 commit e4608eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ pub struct Settings {
pub const fn default_derivation_path(config: ConfigDiscriminants) -> u32 {
match config {
// TODO: what should these be?
ConfigDiscriminants::V1 => 3,
ConfigDiscriminants::V2 => 3,
ConfigDiscriminants::V3 => 3,
ConfigDiscriminants::V1 => 2,
ConfigDiscriminants::V2 => 2,
ConfigDiscriminants::V3 => 2,
}
}

Expand Down
35 changes: 19 additions & 16 deletions gen-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use assert_cmd::prelude::*;
use hpos_config_core::config::ConfigDiscriminants;
use once_cell::sync::Lazy;
// Add methods on commands
use std::process::Command; // Run programs
use std::{process::Command, str::FromStr}; // Run programs

#[derive(Debug, Clone, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -57,8 +57,10 @@ fn gen_with_device_bundle() -> Result<(), Box<dyn std::error::Error>> {
let config_version = if let Some(config_version) = &args.config_version {
config_version.to_string()
} else {
ConfigDiscriminants::default().to_string().replace('v', "")
ConfigDiscriminants::default().to_string()
};
let derivation_path = hpos_config_core::config::default_derivation_path(ConfigDiscriminants::from_str(&config_version)?);

cmd_args.extend_from_slice(&["--config-version", &config_version]);

if let Some(device_bundle) = &args.device_bundle {
Expand All @@ -78,24 +80,25 @@ fn gen_with_device_bundle() -> Result<(), Box<dyn std::error::Error>> {
}

assert_eq!(
clean_str(&output),
clean_str(&r#"
{
"v2": {
clean_str(&output),
clean_str(&format!(
r#"
{{
"v2": {{
"device_bundle": "k6VoY3NiMJGWonB3xBAp9K2BbqRJd0sS3pD1FHcGzhAAAAADxBhyjcHi1prEESr_g9g5aHDUaAm0CloHDBPEMSdaH_eSV94Qi_VUVZ626mV-dAYaHhcCNVbsJ06dWzMQnVtTaQQLtmW_o3qXFmBK6QrEAA",
"derivation_path": "%% derivation_path %%",
"derivation_path": "{derivation_path}",
"registration_code": "jQEAxhmwxrQq1duo7D6K/SiO92tLqNgo67sQ2uHolmlwGQ5y12ZrfFfFGiUvF3Kvf2Qx4aCtu6CYGZy9CtFonQ==",
"settings": {
"admin": {
"settings": {{
"admin": {{
"email": "[email protected]",
"public_key": "8TH/5P1R21uOiCUOevs0f3FE2RwHiLXWoIjbqS8cxWU"
}
}
}
}
"#.replace("%% derivation_path %%", &config_version)
)
);
}}
}}
}}
}}
"#
))
);

Ok(())
}

0 comments on commit e4608eb

Please sign in to comment.