v0.14.0
This commit is contained in:
+25
-1
@@ -1,7 +1,7 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::models::{ApiTokenInfo, Device, HaReading, Reading};
|
||||
use crate::models::{ApiTokenInfo, ConnectionType, Device, HaReading, Reading};
|
||||
|
||||
#[test]
|
||||
fn history_compaction_keeps_one_sample_per_old_bucket() {
|
||||
@@ -129,4 +129,28 @@ mod tests {
|
||||
);
|
||||
assert_eq!(db.history_counts().unwrap(), (1, 0, 1));
|
||||
}
|
||||
#[test]
|
||||
fn local_and_cloud_entries_with_same_physical_mac_can_coexist() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let db = Db::open(&dir.path().join("duplicate-transport.db")).unwrap();
|
||||
let mut local = Device::simulated_default();
|
||||
local.id = "local-device".into();
|
||||
local.mac = "AABBCCDDEEFF".into();
|
||||
local.connection_type = ConnectionType::Local;
|
||||
let mut cloud = local.clone();
|
||||
cloud.id = "cloud-device".into();
|
||||
cloud.connection_type = ConnectionType::GreeCloud;
|
||||
cloud.cloud_device_id = Some(local.mac.clone());
|
||||
cloud.ip.clear();
|
||||
cloud.port = 0;
|
||||
cloud.key = Some("0123456789abcdef".into());
|
||||
|
||||
db.save_device(&local).unwrap();
|
||||
db.save_device(&cloud).unwrap();
|
||||
let devices = db.list_devices().unwrap();
|
||||
assert_eq!(devices.len(), 2);
|
||||
assert!(devices.iter().any(|item| item.connection_type == ConnectionType::Local));
|
||||
assert!(devices.iter().any(|item| item.connection_type == ConnectionType::GreeCloud));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user