pub struct TestSandbox { /* private fields */ }
Expand description
A test sandbox backed by a fnetemul::SandboxProxy
.
TestSandbox
provides various utility methods to set up network realms for
use in testing. The lifetime of the TestSandbox
is tied to the netemul
sandbox itself, dropping it will cause all the created realms, networks, and
endpoints to be destroyed.
Implementations§
Source§impl TestSandbox
impl TestSandbox
Sourcepub fn new() -> Result<TestSandbox, Error>
pub fn new() -> Result<TestSandbox, Error>
Creates a new empty sandbox.
Sourcepub fn create_realm<'a, I>(
&'a self,
name: impl Into<Cow<'a, str>>,
children: I,
) -> Result<TestRealm<'a>, Error>
pub fn create_realm<'a, I>( &'a self, name: impl Into<Cow<'a, str>>, children: I, ) -> Result<TestRealm<'a>, Error>
Creates a realm with name
and children
.
Sourcepub fn create_empty_realm<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
) -> Result<TestRealm<'a>, Error>
pub fn create_empty_realm<'a>( &'a self, name: impl Into<Cow<'a, str>>, ) -> Result<TestRealm<'a>, Error>
Creates a realm with no components.
Sourcepub fn get_network_manager(&self) -> Result<NetworkManagerProxy, Error>
pub fn get_network_manager(&self) -> Result<NetworkManagerProxy, Error>
Connects to the sandbox’s NetworkManager
.
Sourcepub fn get_endpoint_manager(&self) -> Result<EndpointManagerProxy, Error>
pub fn get_endpoint_manager(&self) -> Result<EndpointManagerProxy, Error>
Connects to the sandbox’s EndpointManager
.
Sourcepub async fn create_network<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
) -> Result<TestNetwork<'a>, Error>
pub async fn create_network<'a>( &'a self, name: impl Into<Cow<'a, str>>, ) -> Result<TestNetwork<'a>, Error>
Creates a new empty network with default configurations and name
.
Sourcepub async fn setup_networks<'a>(
&'a self,
networks: Vec<NetworkSetup>,
) -> Result<TestNetworkSetup<'a>, Error>
pub async fn setup_networks<'a>( &'a self, networks: Vec<NetworkSetup>, ) -> Result<TestNetworkSetup<'a>, Error>
Creates new networks and endpoints as specified in networks
.
Sourcepub async fn create_endpoint<'a, S>(
&'a self,
name: S,
) -> Result<TestEndpoint<'a>, Error>
pub async fn create_endpoint<'a, S>( &'a self, name: S, ) -> Result<TestEndpoint<'a>, Error>
Creates a new unattached endpoint with default configurations and name
.
Characters may be dropped from the front of name
if it exceeds the maximum length.
Sourcepub async fn create_endpoint_with<'a>(
&'a self,
name: impl Into<Cow<'a, str>>,
config: EndpointConfig,
) -> Result<TestEndpoint<'a>, Error>
pub async fn create_endpoint_with<'a>( &'a self, name: impl Into<Cow<'a, str>>, config: EndpointConfig, ) -> Result<TestEndpoint<'a>, Error>
Creates a new unattached endpoint with the provided configuration.
Characters may be dropped from the front of name
if it exceeds the maximum length.