Skip to content

Commit 2bdc44d

Browse files
committed
api_server: updated to new API
Signed-off-by: George Pisaltu <[email protected]>
1 parent 62054ef commit 2bdc44d

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/api_server/src/parsed_request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ pub(crate) mod tests {
546546
Server: Firecracker API\r\n\
547547
Connection: keep-alive\r\n\
548548
Content-Type: application/json\r\n\
549-
Content-Length: 88\r\n\r\n{}",
549+
Content-Length: 90\r\n\r\n{}",
550550
serde_json::to_string(&stats).unwrap(),
551551
);
552552
assert_eq!(buf.into_inner(), expected_response.as_bytes());
@@ -650,8 +650,8 @@ pub(crate) mod tests {
650650
.write_all(
651651
b"PUT /balloon HTTP/1.1\r\n\
652652
Content-Type: application/json\r\n\
653-
Content-Length: 74\r\n\r\n{ \
654-
\"amount_mb\": 0, \
653+
Content-Length: 75\r\n\r\n{ \
654+
\"amount_mib\": 0, \
655655
\"deflate_on_oom\": false, \
656656
\"stats_polling_interval_s\": 0 \
657657
}",
@@ -928,7 +928,7 @@ pub(crate) mod tests {
928928
.write_all(
929929
b"PATCH /balloon HTTP/1.1\r\n\
930930
Content-Type: application/json\r\n\
931-
Content-Length: 18\r\n\r\n{ \"amount_mb\": 1 }",
931+
Content-Length: 19\r\n\r\n{ \"amount_mib\": 1 }",
932932
)
933933
.unwrap();
934934
assert!(connection.try_read().is_ok());

src/api_server/src/request/balloon.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,35 @@ mod tests {
6969

7070
// PATCH with invalid fields.
7171
let body = r#"{
72-
"amount_mb": "bar",
72+
"amount_mib": "bar",
7373
"foo": "bar"
7474
}"#;
7575
assert!(parse_patch_balloon(&Body::new(body), None).is_err());
7676

7777
// PATCH with invalid types on fields. Adding a polling interval as string instead of bool.
7878
let body = r#"{
79-
"amount_mb": 1000,
79+
"amount_mib": 1000,
8080
"stats_polling_interval_s": "false"
8181
}"#;
8282
let res = parse_patch_balloon(&Body::new(body), None);
8383
assert!(res.is_err());
8484

85-
// PATCH with invalid types on fields. Adding a amount_mb as a negative number.
85+
// PATCH with invalid types on fields. Adding a amount_mib as a negative number.
8686
let body = r#"{
87-
"amount_mb": -1000,
87+
"amount_mib": -1000,
8888
"stats_polling_interval_s": true
8989
}"#;
9090
let res = parse_patch_balloon(&Body::new(body), None);
9191
assert!(res.is_err());
9292

9393
// PATCH on statistics with missing ppolling interval field.
9494
let body = r#"{
95-
"amount_mb": 100
95+
"amount_mib": 100
9696
}"#;
9797
let res = parse_patch_balloon(&Body::new(body), Some(&"statistics"));
9898
assert!(res.is_err());
9999

100-
// PATCH with missing amount_mb field.
100+
// PATCH with missing amount_mib field.
101101
let body = r#"{
102102
"stats_polling_interval_s": 0
103103
}"#;
@@ -106,7 +106,7 @@ mod tests {
106106

107107
// PATCH that tries to update something else other than allowed fields.
108108
let body = r#"{
109-
"amount_mb": "dummy_id",
109+
"amount_mib": "dummy_id",
110110
"stats_polling_interval_s": "dummy_host"
111111
}"#;
112112
let res = parse_patch_balloon(&Body::new(body), None);
@@ -125,11 +125,11 @@ mod tests {
125125
assert!(parse_patch_balloon(&Body::new(body), Some(&"config")).is_err());
126126

127127
let body = r#"{
128-
"amount_mb": 1
128+
"amount_mib": 1
129129
}"#;
130130
#[allow(clippy::match_wild_err_arm)]
131131
match vmm_action_from_request(parse_patch_balloon(&Body::new(body), None).unwrap()) {
132-
VmmAction::UpdateBalloon(balloon_cfg) => assert_eq!(balloon_cfg.amount_mb, 1),
132+
VmmAction::UpdateBalloon(balloon_cfg) => assert_eq!(balloon_cfg.amount_mib, 1),
133133
_ => panic!("Test failed: Invalid parameters"),
134134
};
135135

@@ -153,14 +153,14 @@ mod tests {
153153

154154
// PUT with invalid fields.
155155
let body = r#"{
156-
"amount_mb": "bar",
156+
"amount_mib": "bar",
157157
"is_read_only": false
158158
}"#;
159159
assert!(parse_put_balloon(&Body::new(body)).is_err());
160160

161161
// PUT with valid input fields.
162162
let body = r#"{
163-
"amount_mb": 1000,
163+
"amount_mib": 1000,
164164
"deflate_on_oom": true,
165165
"stats_polling_interval_s": 0
166166
}"#;

0 commit comments

Comments
 (0)