Fix multicast tests for SQLite.

This commit is contained in:
Orne Brocaar 2024-12-05 12:02:37 +00:00
parent d3692144fa
commit 30b1e0301a

View File

@ -1204,30 +1204,36 @@ pub mod test {
.await .await
.unwrap(); .unwrap();
// Set gateway last_seen_at in the past. // The below features are (currently) for PostgreSQL only.
gateway::partial_update( #[cfg(feature = "postgres")]
gw.gateway_id, {
&gateway::GatewayChangeset { // Set gateway last_seen_at in the past.
last_seen_at: Some(Some(Utc::now() - Duration::days(1))), gateway::partial_update(
..Default::default() gw.gateway_id,
}, &gateway::GatewayChangeset {
) last_seen_at: Some(Some(Utc::now() - Duration::days(1))),
.await ..Default::default()
.unwrap(); },
)
.await
.unwrap();
// We expect zero items, as the gateway is not online. // We expect zero items, as the gateway is not online.
let out = get_schedulable_queue_items(100).await.unwrap(); let out = get_schedulable_queue_items(100).await.unwrap();
assert_eq!(0, out.len()); assert_eq!(0, out.len());
// Set the expires_at of the queue item to now. // Set the expires_at of the queue item to now.
diesel::update(multicast_group_queue_item::dsl::multicast_group_queue_item.find(&qi.id)) diesel::update(
multicast_group_queue_item::dsl::multicast_group_queue_item.find(&qi.id),
)
.set(multicast_group_queue_item::expires_at.eq(Some(Utc::now()))) .set(multicast_group_queue_item::expires_at.eq(Some(Utc::now())))
.execute(&mut get_async_db_conn().await.unwrap()) .execute(&mut get_async_db_conn().await.unwrap())
.await .await
.unwrap(); .unwrap();
// We expect one item, as it has expired. // We expect one item, as it has expired.
let out = get_schedulable_queue_items(100).await.unwrap(); let out = get_schedulable_queue_items(100).await.unwrap();
assert_eq!(1, out.len()); assert_eq!(1, out.len());
}
} }
} }