pub fn make_mocker() -> (Client, KubernetesMocker)
Expand description
Returns (kube client, mock struct).
Use the kubernetes client as normal, both during calls to mocker.expect()
and then during
mocker.run()
.
ยงExamples
let (client, mut mocker) = make_mocker();
let api: Api<Node> = Api::all(client);
mocker.expect(|| async {
let nodes = api.list(&ListParams::default()).await;
},
MockReturn::List(&[Node::default()]),
).await.unwrap();
// ...
let handle = tokio::spawn(mocker.run());
api.list(&ListParams::default()).await;
handle.await.unwrap().unwrap(); // Assert tests pass with `unwrap()`.