MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_gateway

Function test_gateway

chirpstack/src/storage/gateway.rs:611–815  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

609
610 #[tokio::test]
611 async fn test_gateway() {
612 let _guard = test::prepare().await;
613 let mut gw = create_gateway(EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8])).await;
614
615 let app = storage::application::create(storage::application::Application {
616 tenant_id: gw.tenant_id,
617 name: "test-app".into(),
618 ..Default::default()
619 })
620 .await
621 .unwrap();
622
623 let mg = storage::multicast::create(storage::multicast::MulticastGroup {
624 application_id: app.id,
625 name: "test-mg".into(),
626 region: CommonName::EU868,
627 mc_addr: DevAddr::from_be_bytes([1, 2, 3, 4]),
628 mc_nwk_s_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]),
629 f_cnt: 10,
630 group_type: "C".into(),
631 dr: 1,
632 frequency: 868100000,
633 class_b_ping_slot_periodicity: 1,
634 ..Default::default()
635 })
636 .await
637 .unwrap();
638
639 storage::multicast::add_gateway(&mg.id.into(), &gw.gateway_id)
640 .await
641 .unwrap();
642
643 // get
644 let gw_get = get(&gw.gateway_id).await.unwrap();
645 assert_eq!(gw, gw_get);
646
647 // update
648 gw.name = "updated-name".into();
649 gw = update(gw).await.unwrap();
650 let gw_get = get(&gw.gateway_id).await.unwrap();
651 assert_eq!(gw, gw_get);
652
653 // get count and list
654 let tests = vec![
655 FilterTest {
656 filters: Filters {
657 tenant_id: None,
658 multicast_group_id: None,
659 search: None,
660 },
661 gws: vec![&gw],
662 count: 1,
663 limit: 10,
664 offset: 0,
665 order: OrderBy::Name,
666 order_by_desc: false,
667 },
668 FilterTest {

Callers

nothing calls this directly

Calls 11

prepareFunction · 0.85
create_gatewayFunction · 0.85
add_gatewayFunction · 0.85
unwrapMethod · 0.80
createFunction · 0.70
getFunction · 0.70
updateFunction · 0.70
get_countFunction · 0.70
listFunction · 0.70
deleteFunction · 0.70
intoMethod · 0.45

Tested by

no test coverage detected