()
| 1004 | |
| 1005 | #[tokio::test] |
| 1006 | async fn test_gateway() { |
| 1007 | let _guard = test::prepare().await; |
| 1008 | |
| 1009 | let t = tenant::create(tenant::Tenant { |
| 1010 | name: "test-tenant".into(), |
| 1011 | can_have_gateways: true, |
| 1012 | ..Default::default() |
| 1013 | }) |
| 1014 | .await |
| 1015 | .unwrap(); |
| 1016 | |
| 1017 | let app = application::create(application::Application { |
| 1018 | name: "test-app".into(), |
| 1019 | tenant_id: t.id, |
| 1020 | ..Default::default() |
| 1021 | }) |
| 1022 | .await |
| 1023 | .unwrap(); |
| 1024 | |
| 1025 | let gw = gateway::create(gateway::Gateway { |
| 1026 | gateway_id: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]), |
| 1027 | tenant_id: t.id, |
| 1028 | name: "test-gw".into(), |
| 1029 | ..Default::default() |
| 1030 | }) |
| 1031 | .await |
| 1032 | .unwrap(); |
| 1033 | |
| 1034 | let mg = create(MulticastGroup { |
| 1035 | application_id: app.id, |
| 1036 | name: "test-mg".into(), |
| 1037 | region: CommonName::EU868, |
| 1038 | mc_addr: DevAddr::from_be_bytes([1, 2, 3, 4]), |
| 1039 | mc_nwk_s_key: AES128Key::from_bytes([1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8]), |
| 1040 | f_cnt: 10, |
| 1041 | group_type: "C".into(), |
| 1042 | dr: 1, |
| 1043 | frequency: 868100000, |
| 1044 | class_b_ping_slot_periodicity: 1, |
| 1045 | ..Default::default() |
| 1046 | }) |
| 1047 | .await |
| 1048 | .unwrap(); |
| 1049 | |
| 1050 | // add gateway |
| 1051 | add_gateway(&mg.id.into(), &gw.gateway_id).await.unwrap(); |
| 1052 | |
| 1053 | // get gateway ids |
| 1054 | let gw_ids = get_gateway_ids(&mg.id.into()).await.unwrap(); |
| 1055 | assert_eq!(vec![gw.gateway_id], gw_ids); |
| 1056 | |
| 1057 | // remove gateway |
| 1058 | remove_gateway(&mg.id.into(), &gw.gateway_id).await.unwrap(); |
| 1059 | let gw_ids = get_gateway_ids(&mg.id.into()).await.unwrap(); |
| 1060 | assert!(gw_ids.is_empty()); |
| 1061 | } |
| 1062 | |
| 1063 | #[tokio::test] |
nothing calls this directly
no test coverage detected