Skip to main content

Module testkit

Module testkit 

Source
Available on crate feature testkit only.
Expand description

Building blocks for testing an OCPI integration: sample objects and in-memory stores.

Everything here is deliberately dependency-light — no HTTP mocking framework, no test runner — so it can be used from a unit test, an integration test, a fuzz target or a demo binary without dragging a stack along.

use ocpi_kit::testkit::{sample, InMemoryLocations};
use ocpi_kit::types::Validate;

let location = sample::location("LOC1")?;
location.validate()?;

let store = InMemoryLocations::new();
store.put(location.clone());
assert_eq!(store.get("loc1").unwrap().id, location.id);

Re-exports§

pub use stores::InMemoryCdrs;
pub use stores::InMemoryLocations;
pub use stores::InMemorySessions;
pub use stores::InMemoryTariffs;
pub use stores::InMemoryTokens;

Modules§

sample
Valid sample objects, for tests that need an object rather than a specific one.
stores
In-memory object stores, with pagination that behaves the way the specification describes.

Structs§

MockPeerserver
A conformant OCPI party, held in memory.
MockPeerStoresserver
The objects a MockPeer serves, reached through its Deref.

Functions§

bootstrap_peerserver
An AuthenticatedPeer that still holds CREDENTIALS_TOKEN_A, for testing the scope rule.
registered_peerserver
An AuthenticatedPeer for a fully registered platform.
test_cpo
The party a test CPO speaks as.
test_hub
The party a test hub speaks as.
test_msp
The party a test eMSP speaks as.
test_token
A credentials token with a fixed, obviously-fake value.