Skip to content

Commit bb58c4d

Browse files
authored
fix: update docker container running alert (#392)
* fix: update docker container running alert * chore: add tests for docker utils * chore: clippy * chore: remove unnecessary tests * fix: ensure correct network config on deploy
1 parent 8f75b5f commit bb58c4d

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

crates/stellar-scaffold-cli/src/commands/build/clients.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ export default new Client.Client({{
756756
let deploy_cmd = cli::contract::deploy::wasm::Cmd::parse_arg_vec(&deploy_arg_refs)?;
757757
let contract_id = deploy_cmd
758758
.execute(
759-
&deploy_cmd.config,
759+
&self.config(),
760760
self.global_args.quiet,
761761
self.global_args.no_cache,
762762
)

crates/stellar-scaffold-cli/src/commands/build/docker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub async fn start_local_stellar() -> Result<(), Box<dyn Error>> {
66
.run(&stellar_cli::commands::global::Args::default())
77
.await;
88
if let Err(e) = result {
9-
if e.to_string().contains("already in use")
9+
if e.to_string().contains("already running")
1010
|| e.to_string().contains("port is already allocated")
1111
{
1212
eprintln!("Container is already running, proceeding to health check...");
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use stellar_cli::{CommandParser, commands as cli};
2+
3+
/// Make sure that `start_local_stellar` is idempotent. It shouldn't fail if container
4+
/// is already running, it should skip startup logic and proceed to health checks.
5+
#[tokio::test]
6+
async fn start_local_stellar_is_idempotent() {
7+
// Test harness already sets up network, so this is _second_ call
8+
let result = stellar_scaffold_cli::commands::build::docker::start_local_stellar().await;
9+
assert!(
10+
result.is_ok(),
11+
"start_local_stellar should succeed when the container is already running, got: {result:?}"
12+
);
13+
}
14+
15+
/// Directly invoke the underlying `container start` CLI command and assert that
16+
/// the error message still contains at least one of the substrings we rely on
17+
/// to detect an already-running container.
18+
///
19+
/// See: <https://github.com/theahaco/scaffold-stellar/pull/392>
20+
#[tokio::test]
21+
async fn container_start_error_contains_expected_substring() {
22+
let cmd = cli::container::StartCmd::parse_arg_vec(&["local"])
23+
.expect("failed to parse container start command");
24+
25+
let result = cmd
26+
.run(&stellar_cli::commands::global::Args::default())
27+
.await;
28+
29+
// Verify that the error matches what we're expecting
30+
if let Err(e) = result {
31+
let msg = e.to_string();
32+
assert!(
33+
msg.contains("already running") || msg.contains("port is already allocated"),
34+
"Container start error message changed! \
35+
Expected it to contain \"already running\" or \"port is already allocated\", \
36+
but got: \"{msg}\""
37+
);
38+
}
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mod accounts;
22
mod contracts;
3+
mod docker;

0 commit comments

Comments
 (0)