mock
ModuleAn in-memory registrar for tests.
Contents
use utopia_domains::registrar::mock::Mock;Rust
pub struct MockA registrar that keeps its registry in memory: google.com, facebook.com
and amazon.com are taken, com, net, org, io, dev and app are
sold at the default price, a few domains are premium, and purchases and
transfers are remembered.
Rust
use utopia_domains::registrar::{Contact, Mock, Purchase, Registrar};
let contact = Contact {
firstname: "Ada".into(), lastname: "Lovelace".into(), phone: "+18031234567".into(),
email: "ada@example.com".into(), address1: "1 Main St".into(), city: "London".into(),
state: "LDN".into(), country: "GB".into(), postalcode: "N1".into(), ..Contact::default()
};
let registrar = Registrar::new(Mock::new());
tokio::runtime::Runtime::new()?.block_on(async {
let order = registrar.purchase(&Purchase::new("my-app.com", contact)).await?;
assert!(order.starts_with("mock_"));
assert_eq!(registrar.adapter().purchased(), ["my-app.com"]);
Ok::<_, utopia_domains::Error>(())
})?;Also implements
Default.