Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: container-centric API with refactored underlying layer #575

Merged
merged 15 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ keywords = ["docker", "testcontainers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/testcontainers/testcontainers-rs"
rust-version = "1.66"
rust-version = "1.70"

[workspace.dependencies]
testimages = { path = "testimages" }
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,38 @@ The crate provides an API for working with containers in a test environment.

1. Depend on `testcontainers`
2. Implement `testcontainers::core::Image` for necessary docker-images
3. Run it with any available client `testcontainers::clients::*`
3. Run it with any available runner `testcontainers::runners::*` (use `blocking` feature for synchronous API)

#### Example:

- Blocking API (under `blocking` feature)

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

#[test]
fn test_redis() {
let container = GenericImage::new("redis", "latest")
DDtKey marked this conversation as resolved.
Show resolved Hide resolved
.with_exposed_port(6379)
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start();
}
```

- Async API

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

#[tokio::test]
async fn test_redis() {
let container = GenericImage::new("redis", "latest")
.with_exposed_port(6379)
.with_wait_for(WaitFor::message_on_stdout("Ready to accept connections"))
.start()
.await;
}
```

### Ready-to-use images

Expand Down
21 changes: 13 additions & 8 deletions testcontainers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@ repository.workspace = true
rust-version.workspace = true
description = "A library for integration-testing against docker containers from within Rust."

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[dependencies]
async-trait = { version = "0.1", optional = true }
bollard = { version = "0.16.1", optional = true }
async-trait = { version = "0.1" }
bollard = { version = "0.16.1", features = ["ssl"] }
bollard-stubs = "=1.44.0-rc.2"
conquer-once = { version = "0.4", optional = true }
dirs = "5.0.1"
futures = "0.3"
hex = "0.4"
hmac = "0.12"
log = "0.4"
rand = "0.8"
serde = { version = "1", features = ["derive"] }
serde-java-properties = "0.1.1"
serde_json = "1"
sha2 = "0.10"
serde_with = "3.7.0"
signal-hook = { version = "0.3", optional = true }
tokio = { version = "1", features = ["macros"], optional = true }
tokio = { version = "1", features = ["macros", "fs", "rt-multi-thread"] }
tokio-util = "0.7.10"
url = { version = "2", features = ["serde"] }

[features]
default = []
experimental = ["async-trait", "bollard", "tokio"]
blocking = []
watchdog = ["signal-hook", "conquer-once"]

[dev-dependencies]
Expand Down
9 changes: 0 additions & 9 deletions testcontainers/src/clients.rs

This file was deleted.

Loading
Loading