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.