summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_mapper/src
diff options
context:
space:
mode:
authorinitard <solo@softwareag.com>2022-04-28 11:37:33 +0100
committerinitard <solo@softwareag.com>2022-05-03 17:54:08 +0100
commit748d9091ec458b04278a8c9701fbead337a5d83d (patch)
tree100a700bb121fc53882671981586c3e3a89ae8fe /crates/core/tedge_mapper/src
parente27c8e758610166d50c2e1c7ebd64e709c5bf571 (diff)
fixing tests to work with CumulocityConverter changes #1027
- added a from_logs_path method for CumulocityConverter, allowing the possibility to specify tempDir for logs paths Signed-off-by: initard <solo@softwareag.com>
Diffstat (limited to 'crates/core/tedge_mapper/src')
-rw-r--r--crates/core/tedge_mapper/src/c8y/mapper.rs5
-rw-r--r--crates/core/tedge_mapper/src/c8y/tests.rs16
2 files changed, 19 insertions, 2 deletions
diff --git a/crates/core/tedge_mapper/src/c8y/mapper.rs b/crates/core/tedge_mapper/src/c8y/mapper.rs
index b5f9c275..6b5a8b3a 100644
--- a/crates/core/tedge_mapper/src/c8y/mapper.rs
+++ b/crates/core/tedge_mapper/src/c8y/mapper.rs
@@ -123,6 +123,7 @@ mod tests {
use mqtt_tests::{assert_received_all_expected, test_mqtt_broker};
use serde_json::json;
use std::time::Duration;
+ use tempfile::TempDir;
use test_case::test_case;
const TEST_TIMEOUT_SECS: Duration = Duration::from_secs(5);
@@ -180,13 +181,15 @@ mod tests {
let size_threshold = SizeThreshold(MQTT_MESSAGE_SIZE_THRESHOLD);
let operations = Operations::default();
+ let tmp_dir = TempDir::new().unwrap();
let converter = Box::new(
- CumulocityConverter::new(
+ CumulocityConverter::from_logs_path(
size_threshold,
DEVICE_NAME.into(),
DEVICE_TYPE.into(),
operations,
proxy,
+ tmp_dir.into_path(),
)
.unwrap(),
);
diff --git a/crates/core/tedge_mapper/src/c8y/tests.rs b/crates/core/tedge_mapper/src/c8y/tests.rs
index 03477298..2e8ccc0e 100644
--- a/crates/core/tedge_mapper/src/c8y/tests.rs
+++ b/crates/core/tedge_mapper/src/c8y/tests.rs
@@ -19,6 +19,7 @@ use mqtt_tests::test_mqtt_server::MqttProcessHandler;
use serde_json::json;
use serial_test::serial;
use std::{path::Path, time::Duration};
+use tempfile::TempDir;
use test_case::test_case;
use tokio::task::JoinHandle;
@@ -939,12 +940,25 @@ fn create_c8y_converter() -> CumulocityConverter<FakeC8YHttpProxy> {
let operations = Operations::default();
let http_proxy = FakeC8YHttpProxy {};
- CumulocityConverter::new(
+ let tmp_dir = TempDir::new().unwrap();
+ std::fs::create_dir_all(&format!(
+ "{}/tedge/agent/",
+ &tmp_dir.path().to_str().unwrap()
+ ))
+ .unwrap();
+ std::fs::File::create(&format!(
+ "{}/tedge/agent/software-list-2011-11-11T11:11:11Z.log",
+ &tmp_dir.path().to_str().unwrap()
+ ))
+ .unwrap();
+
+ CumulocityConverter::from_logs_path(
size_threshold,
device_name,
device_type,
operations,
http_proxy,
+ tmp_dir.into_path(),
)
.unwrap()
}