Implements a first vertical slice of the Outline RPC API (auth, documents, collections, users) covering the structural patterns used across the whole API: single object, paginated list, tree, create/update, delete, search. Chosen as the basis for future CLI and GUI clients built on top of this crate. - Handwritten client (not codegen) against the vendored OpenAPI spec, since Outline's API is uniformly POST /api/<resource>.<action> with JSON bodies and inline/anonymous schemas that generators handle poorly - Async (reqwest + tokio) Client, cheaply cloneable, no &mut self methods - thiserror-based Error with ErrorKind classification and boxed API error context; forward-compatible models (unknown fields ignored, unknown string-enum values preserved via a catch-all variant) since the API is unversioned and self-hosted instances vary in age - Pagination via Page<T>/Paginator with next_page/collect_all/into_stream - wiremock-based test suite plus a spec-coverage test guarding against typos in RPC method names
30 lines
786 B
Rust
30 lines
786 B
Rust
//! Smoke tests against the real Outline API.
|
|
//!
|
|
//! Ignored by default. Run with:
|
|
//! `OUTLINE_API_KEY=ol_api_... cargo test -- --ignored`
|
|
|
|
use outline::Client;
|
|
|
|
#[tokio::test]
|
|
#[ignore]
|
|
async fn auth_info_and_collections_list_succeed() {
|
|
let client =
|
|
Client::from_env().expect("OUTLINE_API_KEY (and optionally OUTLINE_URL) must be set");
|
|
|
|
let auth = client
|
|
.auth()
|
|
.info()
|
|
.await
|
|
.expect("auth.info should succeed with valid credentials");
|
|
println!("Signed in as {} ({})", auth.user.name, auth.team.name);
|
|
|
|
let page = client
|
|
.collections()
|
|
.list()
|
|
.limit(5)
|
|
.send()
|
|
.await
|
|
.expect("collections.list should succeed");
|
|
println!("Fetched {} collection(s)", page.items.len());
|
|
}
|