()
| 186 | |
| 187 | #[tokio::test] |
| 188 | async fn test_relay() { |
| 189 | let _guard = test::prepare().await; |
| 190 | |
| 191 | // setup admin user |
| 192 | let u = user::User { |
| 193 | is_admin: true, |
| 194 | is_active: true, |
| 195 | email: "admin@admin".into(), |
| 196 | email_verified: true, |
| 197 | ..Default::default() |
| 198 | }; |
| 199 | let u = user::create(u).await.unwrap(); |
| 200 | |
| 201 | // create tenant |
| 202 | let t = tenant::create(tenant::Tenant { |
| 203 | name: "test-tenant".into(), |
| 204 | ..Default::default() |
| 205 | }) |
| 206 | .await |
| 207 | .unwrap(); |
| 208 | |
| 209 | // create application |
| 210 | let app = application::create(application::Application { |
| 211 | name: "test-app".into(), |
| 212 | tenant_id: t.id, |
| 213 | ..Default::default() |
| 214 | }) |
| 215 | .await |
| 216 | .unwrap(); |
| 217 | |
| 218 | // create device-profile |
| 219 | let dp = device_profile::create(device_profile::DeviceProfile { |
| 220 | name: "test-dp".into(), |
| 221 | tenant_id: Some(t.id), |
| 222 | ..Default::default() |
| 223 | }) |
| 224 | .await |
| 225 | .unwrap(); |
| 226 | |
| 227 | // create relay device-profile |
| 228 | let dp_relay = device_profile::create(device_profile::DeviceProfile { |
| 229 | name: "test-dp".into(), |
| 230 | tenant_id: Some(t.id), |
| 231 | relay_params: Some(fields::RelayParams { |
| 232 | is_relay: true, |
| 233 | ..Default::default() |
| 234 | }), |
| 235 | ..Default::default() |
| 236 | }) |
| 237 | .await |
| 238 | .unwrap(); |
| 239 | |
| 240 | // create devices |
| 241 | let d_relay = device::create(device::Device { |
| 242 | name: "relay-device".into(), |
| 243 | dev_eui: EUI64::from_be_bytes([1, 2, 3, 4, 5, 6, 7, 8]), |
| 244 | device_profile_id: dp_relay.id, |
| 245 | application_id: app.id, |
nothing calls this directly
no test coverage detected