Skip to main content

Mock

Struct Mock 

Source
pub struct Mock {
    pub estate: Mutex<Estate>,
    pub heard: Mutex<BTreeMap<String, Heard>>,
    pub calls: Option<Mutex<Vec<(u16, String, String, String)>>>,
    pub log: bool,
}
Expand description

The whole mock: one estate behind one lock. A real UpCloud account is one serialized thing too — two POST /1.3/storage calls do not interleave — so the lock is not a simplification, it is the provider’s own concurrency.

Fields§

§estate: Mutex<Estate>§heard: Mutex<BTreeMap<String, Heard>>

Behaviour 63: who the mock has heard from. Per credential DIGEST (sha256 of the bearer value, never the value): how many requests, how many of them GET /1.3/account. The terraform provider reaches this mock only through the undocumented UPCLOUD_DEBUG_API_BASE_URL; a release that drops it would send a “mock” run to the account. A verb that mints a per-run token and asks /mock/heard before apply or destroy proves the provider spoke to THIS mock, or refuses.

§calls: Option<Mutex<Vec<(u16, String, String, String)>>>

Every call, (status, method, path, error_code), when built with Mock::recording. The terraform contract test reads it; a storm never turns it on.

§log: bool

Log every call, in order, on stderr. Off by default and never on in a storm: a hundred thousand purchases is ten million lines.

It exists because the ORDER a client calls in is a fact about the client that nothing else in this crate can show, and on 2026-09-21 that order was the whole question — UpCloudLtd/upcloud 5.44.1 met SERVER_STATE_ILLEGAL on a filesystem resize and there was no way to tell whether it had resized before stopping, after starting, or whether the mock had simply never finished the stop. A mock that reproduces provider defects and cannot say what was called when is asking every user to guess.

Implementations§

Source§

impl Mock

Source

pub fn new(estate: Estate) -> Arc<Mock>

Source

pub fn recording(estate: Estate) -> Arc<Mock>

The same mock, keeping every call for a test to read (Mock::calls).

Source

pub fn logging(estate: Estate) -> Arc<Mock>

The same mock, narrating. See Mock::log.

Source§

impl Mock

Source

pub fn heard_from(&self, digest: &str) -> Heard

What the mock heard from the credential whose sha256 is digest.

Auto Trait Implementations§

§

impl !Freeze for Mock

§

impl RefUnwindSafe for Mock

§

impl Send for Mock

§

impl Sync for Mock

§

impl Unpin for Mock

§

impl UnsafeUnpin for Mock

§

impl UnwindSafe for Mock

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.