Skip to main content

Module testing

Module testing 

Source
Expand description

Docker-based SMB test servers for integration testing.

Provides TestServers for starting Samba containers on demand, with factory methods that return connected SmbClient instances. Enable the testing feature flag to use this module.

§Three-layer testing model

Layer 1: Rust integration tests – Use TestServers to get pre-connected clients in #[tokio::test] functions.

Layer 2: E2E tests – Use write_compose_files to extract embedded Docker infrastructure, then run docker compose up from your test framework (Playwright, Cypress, etc.).

Layer 3: Manual QA – Extract compose files once, run containers manually, browse virtual servers in your app during development.

§Example

use std::sync::LazyLock;
use smb2::testing::TestServers;

static SERVERS: LazyLock<TestServers> = LazyLock::new(|| {
    TestServers::start_blocking().unwrap()
});

let mut guest = SERVERS.guest_client().await.unwrap();
let shares = guest.list_shares().await.unwrap();

Structs§

TestServers
Docker-based SMB test servers for integration testing.

Enums§

Error
Errors from the test infrastructure (Docker, process, health checks).

Functions§

auth_port
Port for the auth-required container.
both_port
Port for the mixed auth container.
deepnest_port
Port for the deep-nesting container.
flaky_port
Port for the flaky container.
guest_port
Port for the guest-access container.
linux_port
Port for the Linux container.
longnames_port
Port for the long-names container.
many_shares_port
Port for the 50-shares container.
manyfiles_port
Port for the many-files container.
maxreadsize_port
Port for the max-read-size container.
readonly_port
Port for the read-only container.
slow_port
Port for the slow container.
synology_port
Port for the Synology-like container.
unicode_port
Port for the unicode container.
windows_port
Port for the Windows-like container.
write_compose_files
Write all embedded Docker files to the given directory.

Type Aliases§

Result
Result type for test infrastructure operations.