Skip to content

Commit

Permalink
docs: update examples of GenericImage::with_exposed_port (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
DDtKey committed Jun 25, 2024
1 parent d9ce9dc commit 408d323
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ The crate provides an API for working with containers in a test environment.
- Blocking API (under `blocking` feature)

```rust
use testcontainers::{core::WaitFor, runners::SyncRunner, GenericImage};
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::SyncRunner, GenericImage};

#[test]
fn test_redis() {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379)
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()
.expect("Redis started");
Expand All @@ -37,12 +37,12 @@ fn test_redis() {
- Async API

```rust
use testcontainers::{core::WaitFor, runners::AsyncRunner, GenericImage};
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, GenericImage};

#[tokio::test]
async fn test_redis() {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379)
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()
.await
Expand Down
8 changes: 4 additions & 4 deletions docs/quickstart/testcontainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ cargo add testcontainers --features blocking
## 3. Spin up Redis

```rust
use testcontainers::{core::WaitFor, runners::AsyncRunner, GenericImage};
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, GenericImage};

#[tokio::test]
async fn test_redis() -> Result<(), Box<dyn std::error::Error + 'static>> {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379)
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()?
.await;
Expand Down Expand Up @@ -68,12 +68,12 @@ This code gets the endpoint from the container we just started, and it configure
```rust
use redis::Client;
use testcontainers::{core::WaitFor, runners::AsyncRunner, GenericImage};
use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::AsyncRunner, GenericImage};

#[tokio::test]
async fn test_redis() -> Result<(), Box<dyn std::error::Error + 'static>> {
let container = GenericImage::new("redis", "7.2.4")
.with_exposed_port(6379)
.with_exposed_port(6379.tcp())
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()?
.await;
Expand Down
2 changes: 1 addition & 1 deletion testcontainers/src/runners/sync_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static ASYNC_RUNTIME: OnceLock<Mutex<Weak<tokio::runtime::Runtime>>> = OnceLock:
/// ## Example
///
/// ```rust,no_run
/// use testcontainers::{core::{WaitFor, IntoContainerPort}, runners::SyncRunner, GenericImage};
/// use testcontainers::{core::{IntoContainerPort, WaitFor}, runners::SyncRunner, GenericImage};
///
/// fn test_redis() {
/// let container = GenericImage::new("redis", "7.2.4")
Expand Down

0 comments on commit 408d323

Please sign in to comment.