Skip to content

Commit 1e5c40c

Browse files
committed
api_server: expose block flush in the API server
Signed-off-by: George Pisaltu <[email protected]>
1 parent f31435e commit 1e5c40c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/api_server/src/parsed_request.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ pub(crate) mod tests {
643643
\"is_root_device\": true, \
644644
\"partuuid\": \"string\", \
645645
\"is_read_only\": true, \
646+
\"cache_type\": \"Unsafe\", \
646647
\"rate_limiter\": { \
647648
\"bandwidth\": { \
648649
\"size\": 0, \

src/api_server/src/request/drive.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,33 @@ mod tests {
216216
assert!(parse_put_drive(&Body::new("invalid_payload"), None).is_err());
217217
assert!(parse_put_drive(&Body::new("invalid_payload"), Some(&"id")).is_err());
218218

219-
// PATCH with invalid fields.
219+
// PUT with invalid fields.
220220
let body = r#"{
221221
"drive_id": "bar",
222222
"is_read_only": false
223223
}"#;
224224
assert!(parse_put_drive(&Body::new(body), Some(&"2")).is_err());
225225

226-
// PATCH with invalid types on fields. Adding a drive_id as number instead of string.
226+
// PUT with missing all optional fields.
227+
let body = r#"{
228+
"drive_id": "1000",
229+
"path_on_host": "dummy",
230+
"is_root_device": true,
231+
"is_read_only": true
232+
}"#;
233+
assert!(parse_put_drive(&Body::new(body), Some(&"1000")).is_ok());
234+
235+
// PUT with invalid types on fields. Adding a drive_id as number instead of string.
236+
assert!(parse_put_drive(&Body::new(body), Some(&"foo")).is_err());
237+
238+
// PUT with the complete configuration.
227239
let body = r#"{
228240
"drive_id": "1000",
229241
"path_on_host": "dummy",
230242
"is_root_device": true,
231243
"partuuid": "string",
232244
"is_read_only": true,
245+
"cache_type": "Unsafe",
233246
"rate_limiter": {
234247
"bandwidth": {
235248
"size": 0,
@@ -244,7 +257,5 @@ mod tests {
244257
}
245258
}"#;
246259
assert!(parse_put_drive(&Body::new(body), Some(&"1000")).is_ok());
247-
248-
assert!(parse_put_drive(&Body::new(body), Some(&"foo")).is_err());
249260
}
250261
}

0 commit comments

Comments
 (0)