Skip to content

Commit

Permalink
api_server: consistently organize unit tests
Browse files Browse the repository at this point in the history
Some nit changes for consistently organizing unit tests
across all types of requests.

Signed-off-by: Diana Popa <[email protected]>
  • Loading branch information
dianpopa authored and alxiord committed Jan 23, 2020
1 parent c305a0f commit 1f931c6
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/api_server/src/request/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use request::{Body, Error, ParsedRequest, StatusCode};
// The names of the members from this enum must precisely correspond (as a string) to the possible
// values of "action_type" from the json request body. This is useful to get a strongly typed
// struct from the Serde deserialization process.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
enum ActionType {
BlockDeviceRescan,
FlushMetrics,
Expand All @@ -20,9 +20,9 @@ enum ActionType {

// The model of the json body from a sync request. We use Serde to transform each associated
// json body into this.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct ActionBody {
struct ActionBody {
action_type: ActionType,
#[serde(skip_serializing_if = "Option::is_none")]
payload: Option<Value>,
Expand Down Expand Up @@ -162,7 +162,7 @@ mod tests {
}

#[test]
fn test_into_parsed_request() {
fn test_parse_put_actions_request() {
{
assert!(parse_put_actions(&Body::new("invalid_body")).is_err());

Expand Down
4 changes: 2 additions & 2 deletions src/api_server/src/request/drive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ mod tests {
use super::*;

#[test]
fn test_parse_patch_request() {
fn test_parse_patch_drive_request() {
assert!(parse_patch_drive(&Body::new("invalid_payload"), None).is_err());
assert!(parse_patch_drive(&Body::new("invalid_payload"), Some(&"id")).is_err());

Expand Down Expand Up @@ -218,7 +218,7 @@ mod tests {
}

#[test]
fn test_parse_put_request() {
fn test_parse_put_drive_request() {
assert!(parse_put_drive(&Body::new("invalid_payload"), None).is_err());
assert!(parse_put_drive(&Body::new("invalid_payload"), Some(&"id")).is_err());

Expand Down
2 changes: 1 addition & 1 deletion src/api_server/src/request/instance_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod tests {
use super::*;

#[test]
fn test_parse_request() {
fn test_parse_get_instance_info_request() {
match parse_get_instance_info() {
Ok(ParsedRequest::GetInstanceInfo) => {}
_ => panic!("Test failed."),
Expand Down
2 changes: 1 addition & 1 deletion src/api_server/src/request/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod tests {
use vmm::vmm_config::logger::LoggerLevel;

#[test]
fn test_parse_logger_request() {
fn test_parse_put_logger_request() {
let body = r#"{
"log_fifo": "log",
"metrics_fifo": "metrics",
Expand Down
4 changes: 2 additions & 2 deletions src/api_server/src/request/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod tests {
use super::*;

#[test]
fn parse_put_net_request() {
fn test_parse_put_net_request() {
let body = r#"{
"iface_id": "foo",
"host_dev_name": "bar",
Expand Down Expand Up @@ -105,7 +105,7 @@ mod tests {
}

#[test]
fn parse_patch_net_request() {
fn test_parse_patch_net_request() {
let body = r#"{
"iface_id": "foo",
"rx_rate_limiter": {
Expand Down
2 changes: 1 addition & 1 deletion src/api_server/src/request/vsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod tests {
use super::*;

#[test]
fn test_parse_vsock_request() {
fn test_parse_put_vsock_request() {
let body = r#"{
"vsock_id": "foo",
"guest_cid": 42,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/build/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import host_tools.cargo_build as host # pylint: disable=import-error

COVERAGE_TARGET_PCT = 84.90
COVERAGE_TARGET_PCT = 85.10
COVERAGE_MAX_DELTA = 0.05

CARGO_KCOV_REL_PATH = os.path.join(host.CARGO_BUILD_REL_PATH, 'kcov')
Expand Down

0 comments on commit 1f931c6

Please sign in to comment.