An in-memory rust implementation of Kafka Connect compatible REST API designed for testing.
In your Cargo.toml
file, add
[dev-dependencies]
kcmockserver = { git = "https://github.com/A-Fayez/kcmockserver.git" }
In your rust code:
#[test]
fn test() {
// new() spawns a new in-memory server instance in a new background thread
// so that your calling code could be async or not
let server = KcTestServer::new();
let endpoint = format!("{}{}", server.base_url().to_string(), "connectors");
// here we're using reqwest crate to make the api call but any async or blocking http client can be used
let reqwest_uri = reqwest::Url::from_str(&endpoint).unwrap();
let response = reqwest::blocking::get(reqwest_uri).unwrap().text().unwrap();
assert_eq!(response, "[]");
}
Endpoint | Method | Status |
---|---|---|
/connectors | GET | ✅ |
/connectors | POST | ✅ |
/connectors/:name | GET | ✅ |