kubernetes-mock-rs
Mock Kubernetes client for testing things that interact with the Kubernetes API, including controllers.
View documentation, examples, and more by running make doc. (link to docs.rs to come when published!)
488 lines of code, but that's 24% doc comments.
Features
- Very simple to mock, just make the same API calls as your program should make
- Easy setup errors with good documentation - if there are problems, it should help you solve them
- Verbose errors when tests fail, showing you exactly what went wrong
- Works with multiple versions of Kubernetes (currently v1.25, v1.21) - to change versions, please use features
v1_25orv1_21.- Default is v1.25, if you want to use a different version please remember to use
default-features = falsein your Cargo.toml
- Default is v1.25, if you want to use a different version please remember to use
Example
Minimal compilable example:
use *;
use ;
use Node;
async
Note: unwrap() is not great for formatting, if you'd like to see errors pretty printed you can do the following:
if let Err = handle.await.unwrap
Still Todo
- Testing
mocker.watch()- it works but is not tested.- We could use a controller to test this, to show how it works.
- More edge cases tested - functions passed to
expect()panicking, etc. - Explore better API design?
- Can we let
expect()take multiple API calls, meaning people can use one for all API calls
- Can we let
- Should/could we be less restrictive (e.g. unordered API calls, allowing the same call multiple times/"more than once", allowing different parameters)?
Feel free to help, check out CONTRIBUTING.md!
Distributed under Apache 2.0. See LICENSE for more information.