-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split
deploy
into smaller functions
The smaller functions are easier to test and don't require as much mocking setup.
- Loading branch information
Showing
5 changed files
with
212 additions
and
225 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
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,72 @@ | ||
use super::super::{CloudProvider, TestnetDeploy}; | ||
use super::setup::*; | ||
use crate::ansible::MockAnsibleRunnerInterface; | ||
use crate::terraform::MockTerraformRunnerInterface; | ||
use color_eyre::Result; | ||
use mockall::predicate::*; | ||
|
||
#[tokio::test] | ||
async fn should_run_terraform_apply() -> Result<()> { | ||
let (tmp_dir, working_dir) = setup_working_directory()?; | ||
let s3_repository = setup_default_s3_repository(&working_dir)?; | ||
let mut terraform_runner = MockTerraformRunnerInterface::new(); | ||
terraform_runner | ||
.expect_workspace_select() | ||
.times(1) | ||
.with(eq("beta".to_string())) | ||
.returning(|_| Ok(())); | ||
terraform_runner | ||
.expect_apply() | ||
.times(1) | ||
.with(eq(vec![ | ||
("node_count".to_string(), "30".to_string()), | ||
("use_custom_bin".to_string(), "false".to_string()), | ||
])) | ||
.returning(|_| Ok(())); | ||
|
||
let testnet = TestnetDeploy::new( | ||
Box::new(terraform_runner), | ||
Box::new(MockAnsibleRunnerInterface::new()), | ||
working_dir.to_path_buf(), | ||
CloudProvider::DigitalOcean, | ||
s3_repository, | ||
); | ||
|
||
testnet.create_infra("beta", 30, false).await?; | ||
|
||
drop(tmp_dir); | ||
Ok(()) | ||
} | ||
|
||
#[tokio::test] | ||
async fn should_run_terraform_apply_with_custom_bin_set_when_repo_is_supplied() -> Result<()> { | ||
let (tmp_dir, working_dir) = setup_working_directory()?; | ||
let s3_repository = setup_default_s3_repository(&working_dir)?; | ||
let mut terraform_runner = MockTerraformRunnerInterface::new(); | ||
terraform_runner | ||
.expect_workspace_select() | ||
.times(1) | ||
.with(eq("beta".to_string())) | ||
.returning(|_| Ok(())); | ||
terraform_runner | ||
.expect_apply() | ||
.times(1) | ||
.with(eq(vec![ | ||
("node_count".to_string(), "30".to_string()), | ||
("use_custom_bin".to_string(), "true".to_string()), | ||
])) | ||
.returning(|_| Ok(())); | ||
|
||
let testnet = TestnetDeploy::new( | ||
Box::new(terraform_runner), | ||
Box::new(MockAnsibleRunnerInterface::new()), | ||
working_dir.to_path_buf(), | ||
CloudProvider::DigitalOcean, | ||
s3_repository, | ||
); | ||
|
||
testnet.create_infra("beta", 30, true).await?; | ||
|
||
drop(tmp_dir); | ||
Ok(()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
mod clean; | ||
mod deploy; | ||
mod create_infra; | ||
mod init; | ||
mod provision_genesis_node; | ||
mod setup; | ||
|
||
const RPC_CLIENT_BIN_NAME: &str = "safenode_rpc_client"; |
Oops, something went wrong.