Skip to main content

TestServers

Struct TestServers 

Source
pub struct TestServers { /* private fields */ }
Expand description

Docker-based SMB test servers for integration testing.

Starts Samba containers on construction, stops on drop. Each server type has a factory method returning a connected SmbClient.

Consumers can also skip TestServers entirely and use the compose files directly for E2E or manual testing via write_compose_files.

Implementations§

Source§

impl TestServers

Source

pub async fn start() -> Result<Self>

Start the minimal set: guest + auth containers.

This is the fastest option (~2 seconds). Use start_all if you need all 14 containers.

Source

pub async fn start_all() -> Result<Self>

Start all 14 consumer containers.

Source

pub fn start_blocking() -> Result<Self>

Blocking version of start_all for use in LazyLock statics.

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

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

pub async fn guest_client(&self) -> Result<SmbClient>

Guest-access server. No credentials needed.

Source

pub async fn auth_client(&self, user: &str, pass: &str) -> Result<SmbClient>

Auth-required server. Needs username and password.

Source

pub async fn both_client(&self) -> Result<SmbClient>

Mixed server, guest connection. Can access the “public” share only.

Source

pub async fn both_client_auth( &self, user: &str, pass: &str, ) -> Result<SmbClient>

Mixed server, authenticated connection. Can access both “public” and “private” shares.

Source

pub async fn readonly_client(&self) -> Result<SmbClient>

Read-only server. Writes return errors.

Source

pub async fn many_shares_client(&self) -> Result<SmbClient>

Server with 50 shares for testing share enumeration at scale.

Source

pub async fn unicode_client(&self) -> Result<SmbClient>

Server with unicode share and file names (CJK, emoji, accented characters).

Source

pub async fn longnames_client(&self) -> Result<SmbClient>

Server with 200+ character filenames. Tests path truncation.

Source

pub async fn deepnest_client(&self) -> Result<SmbClient>

Server with 50-level deep directory tree. Tests navigation overflow.

Source

pub async fn many_files_client(&self) -> Result<SmbClient>

Server with 10,000+ files in one directory.

Source

pub async fn windows_client(&self) -> Result<SmbClient>

Windows-like server (server string in smb.conf). Tests OS detection.

Source

pub async fn synology_client(&self) -> Result<SmbClient>

Synology-like server (server string in smb.conf). Tests NAS-specific UI.

Source

pub async fn linux_client(&self) -> Result<SmbClient>

Generic Linux Samba server. Most common real-world server type.

Source

pub async fn flaky_client(&self) -> Result<SmbClient>

Flaky server (5 seconds up, 5 seconds down). Tests error recovery UI.

Source

pub async fn slow_client(&self) -> Result<SmbClient>

Slow server (200ms latency). Tests loading states and timeouts.

Trait Implementations§

Source§

impl Drop for TestServers

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.