Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/functions/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ pub async fn insert_functions(
client: &ApiClient,
functions: &[Value],
) -> Result<InsertFunctionsResult> {
let body = serde_json::json!({ "functions": functions });
let body = insert_functions_body(functions);
let raw: Value = client
.post("/insert-functions", &body)
.await
Expand All @@ -249,6 +249,10 @@ pub async fn insert_functions(
})
}

pub(crate) fn insert_functions_body(functions: &[Value]) -> Value {
serde_json::json!({ "functions": functions })
}

fn ignored_count(raw: &Value) -> Option<usize> {
raw.get("ignored_count")
.and_then(Value::as_u64)
Expand All @@ -273,6 +277,14 @@ mod tests {
assert_eq!(ignored_count(&serde_json::json!({})), None);
}

#[test]
fn insert_functions_body_wraps_functions_array() {
let functions = vec![serde_json::json!({ "slug": "demo" })];
let body = insert_functions_body(&functions);

assert_eq!(body, serde_json::json!({ "functions": functions }));
}

#[test]
fn parse_function_list_page_allows_non_paginated_shape() {
let raw = serde_json::json!({
Expand Down
Loading
Loading