test(gpodder_sqlite): start device tests
This commit is contained in:
parent
22016fe0e9
commit
73988d6264
6 changed files with 51 additions and 7 deletions
|
|
@ -104,7 +104,7 @@ fn test_refresh_session() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn remove_old_sessions() {
|
||||
fn test_remove_old_sessions() {
|
||||
let (store, users) = common::setup();
|
||||
|
||||
let now = chrono::Utc::now().trunc_subsecs(0);
|
||||
|
|
|
|||
41
gpodder_sqlite/tests/device_test.rs
Normal file
41
gpodder_sqlite/tests/device_test.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
mod common;
|
||||
|
||||
use gpodder::{DevicePatch, DeviceRepository, DeviceType};
|
||||
|
||||
#[test]
|
||||
fn test_insert_devices() {
|
||||
let (store, users) = common::setup();
|
||||
|
||||
store.devices_for_user(&users[0]).unwrap();
|
||||
|
||||
store
|
||||
.update_device_info(
|
||||
&users[0],
|
||||
"device1",
|
||||
DevicePatch {
|
||||
caption: Some("caption1".to_string()),
|
||||
r#type: Some(DeviceType::Other),
|
||||
},
|
||||
)
|
||||
.expect("update info shouldn't fail");
|
||||
|
||||
store
|
||||
.update_device_info(
|
||||
&users[1],
|
||||
"device2",
|
||||
DevicePatch {
|
||||
caption: Some("caption2".to_string()),
|
||||
r#type: Some(DeviceType::Laptop),
|
||||
},
|
||||
)
|
||||
.expect("update info shouldn't fail");
|
||||
|
||||
let devices = store.devices_for_user(&users[0]);
|
||||
assert!(matches!(devices, Ok(_)));
|
||||
|
||||
let devices = devices.unwrap();
|
||||
assert_eq!(devices.len(), 1);
|
||||
|
||||
assert_eq!(devices[0].caption, "caption1");
|
||||
assert_eq!(devices[0].r#type, DeviceType::Other);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue