Skip to content

Commit

Permalink
move unit tests inside connection info file (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ authored May 21, 2024
1 parent 853b4fd commit 96da7ba
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 41 deletions.
38 changes: 36 additions & 2 deletions src/platform/connection_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use serde_json::Map as JsonMap;
use serde_json::Value as JsonValue;
use std::fs::File;

mod tests;


#[derive(Debug)]
pub enum CiErrorType {
Expand Down Expand Up @@ -251,3 +249,39 @@ impl ConnectionInfo {

}


// ----------------------------------------------------------------------------
#[test]
fn build_from_json_value_ok() {
let input = json!({
"host": {
"addr": "192.168.1.1",
"port": 5555,
}
});
let output = ConnectionInfo::build_from_json_value(input);
assert_eq!(output.is_err(), false);
let ci = output.unwrap();
assert_eq!(ci.host_addr(), "192.168.1.1");
assert_eq!(ci.host_port(), 5555);
}

// ----------------------------------------------------------------------------
#[test]
fn build_from_json_value_fail_0() {
let input = JsonValue::Null;
let output = ConnectionInfo::build_from_json_value(input);
assert_eq!(output.is_err(), true);
}

// ----------------------------------------------------------------------------
#[test]
fn build_from_json_value_fail_1() {
let input = json!({
"hostname": "localhost",
"port": 1883
});
let output = ConnectionInfo::build_from_json_value(input);
assert_eq!(output.is_err(), true);
}

39 changes: 0 additions & 39 deletions src/platform/connection_info/tests.rs

This file was deleted.

0 comments on commit 96da7ba

Please sign in to comment.