pinakes-server: add utoipa annotations to all routes; fix tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
This commit is contained in:
parent
8bde7f8fc2
commit
625077f341
60 changed files with 3493 additions and 242 deletions
|
|
@ -51,7 +51,26 @@ async fn notes_graph_empty() {
|
|||
.unwrap();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
let body = response_body(resp).await;
|
||||
assert!(body.is_object() || body.is_array());
|
||||
// Fresh database: graph must be empty.
|
||||
if let Some(arr) = body.as_array() {
|
||||
assert!(arr.is_empty(), "graph should be empty, got {arr:?}");
|
||||
} else if let Some(obj) = body.as_object() {
|
||||
// Accept an object if the schema uses {nodes:[], edges:[]} style.
|
||||
let nodes_empty = obj
|
||||
.get("nodes")
|
||||
.and_then(|v| v.as_array())
|
||||
.map_or(true, |a| a.is_empty());
|
||||
let edges_empty = obj
|
||||
.get("edges")
|
||||
.and_then(|v| v.as_array())
|
||||
.map_or(true, |a| a.is_empty());
|
||||
assert!(
|
||||
nodes_empty && edges_empty,
|
||||
"graph should be empty, got {obj:?}"
|
||||
);
|
||||
} else {
|
||||
panic!("expected array or object, got {body}");
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
@ -62,6 +81,12 @@ async fn unresolved_count_zero() {
|
|||
.await
|
||||
.unwrap();
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
let body = response_body(resp).await;
|
||||
// Fresh database has no unresolved links.
|
||||
let count = body["count"]
|
||||
.as_u64()
|
||||
.expect("response should have a numeric 'count' field");
|
||||
assert_eq!(count, 0, "expected zero unresolved links in fresh database");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue