Skip to content

Commit 8a34464

Browse files
committed
docs: update
1 parent 86fa407 commit 8a34464

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/features/wait_strategies.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ enum with the following variants:
1414
* `Healthcheck` - wait for the container to be healthy
1515
* `Http` - wait for an HTTP(S) response with predefined conditions (see [`HttpWaitStrategy`](https://docs.rs/testcontainers/latest/testcontainers/core/wait/struct.HttpWaitStrategy.html) for more details)
1616
* `Duration` - wait for a specific duration. Usually less preferable and better to combine with other strategies.
17-
* `SuccessfulCommand` - wait for a given command to exit successfully (exit code 0).
17+
* `Command` - wait for a given command to exit successfully (exit code 0).
18+
19+
## Waiting for a command
20+
21+
You can wait for a specific command on an image with a specific error code if you wish. For example, let's wait for a Testcontainer with a Postgres image to be ready by checking for the successful exit code `0` of `pg_isready`:
22+
23+
```rust
24+
let container = GenericImage::new("postgres", "latest").with_wait_for(WaitFor::command(
25+
ExecCommand::new(["pg_isready"]).with_cmd_ready_condition(CmdWaitFor::exit_code(0)),
26+
));
27+
```
1828

1929
[`Image`](https://docs.rs/testcontainers/latest/testcontainers/core/trait.Image.html) implementation
2030
is responsible for returning the appropriate `WaitFor` strategies.

0 commit comments

Comments
 (0)