Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit 657a43f

Browse files
committed
chore: rearrange
1 parent ab8e369 commit 657a43f

1 file changed

Lines changed: 95 additions & 95 deletions

File tree

‎tests/integration.rs‎

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,101 @@ async fn test_call_migrate_twice() {
11101110
}
11111111
}
11121112

1113+
#[tokio::test]
1114+
async fn test_get_subscriber_accounts_by_project_id() {
1115+
let (_, postgres) = get_dbs().await;
1116+
1117+
let project_id = ProjectId::generate();
1118+
let app_domain = &generate_app_domain();
1119+
let topic = Topic::generate();
1120+
let (signing_secret, signing_public) = generate_signing_keys();
1121+
let (authentication_secret, authentication_public) = generate_authentication_keys();
1122+
upsert_project(
1123+
project_id.clone(),
1124+
app_domain,
1125+
topic,
1126+
authentication_public,
1127+
authentication_secret,
1128+
signing_public,
1129+
signing_secret,
1130+
&postgres,
1131+
)
1132+
.await
1133+
.unwrap();
1134+
let project = get_project_by_project_id(project_id.clone(), &postgres)
1135+
.await
1136+
.unwrap();
1137+
1138+
let account = generate_account_id();
1139+
let scope = HashSet::from(["scope1".to_string(), "scope2".to_string()]);
1140+
let notify_key = rand::Rng::gen::<[u8; 32]>(&mut rand::thread_rng());
1141+
let notify_topic = sha256::digest(&notify_key).into();
1142+
upsert_subscriber(
1143+
project.id,
1144+
account.clone(),
1145+
scope,
1146+
&notify_key,
1147+
notify_topic,
1148+
&postgres,
1149+
)
1150+
.await
1151+
.unwrap();
1152+
1153+
let accounts = get_subscriber_accounts_by_project_id(project_id, &postgres)
1154+
.await
1155+
.unwrap();
1156+
assert_eq!(accounts, vec![account]);
1157+
}
1158+
1159+
#[tokio::test]
1160+
async fn test_get_subscriber_accounts_and_scopes_by_project_id() {
1161+
let (_, postgres) = get_dbs().await;
1162+
1163+
let project_id = ProjectId::generate();
1164+
let app_domain = &generate_app_domain();
1165+
let topic = Topic::generate();
1166+
let (signing_secret, signing_public) = generate_signing_keys();
1167+
let (authentication_secret, authentication_public) = generate_authentication_keys();
1168+
upsert_project(
1169+
project_id.clone(),
1170+
app_domain,
1171+
topic,
1172+
authentication_public,
1173+
authentication_secret,
1174+
signing_public,
1175+
signing_secret,
1176+
&postgres,
1177+
)
1178+
.await
1179+
.unwrap();
1180+
let project = get_project_by_project_id(project_id.clone(), &postgres)
1181+
.await
1182+
.unwrap();
1183+
1184+
let account = generate_account_id();
1185+
let scope = HashSet::from(["scope1".to_string(), "scope2".to_string()]);
1186+
let notify_key = rand::Rng::gen::<[u8; 32]>(&mut rand::thread_rng());
1187+
let notify_topic = sha256::digest(&notify_key).into();
1188+
upsert_subscriber(
1189+
project.id,
1190+
account.clone(),
1191+
scope.clone(),
1192+
&notify_key,
1193+
notify_topic,
1194+
&postgres,
1195+
)
1196+
.await
1197+
.unwrap();
1198+
1199+
let subscribers = get_subscriber_accounts_and_scopes_by_project_id(project_id, &postgres)
1200+
.await
1201+
.unwrap();
1202+
assert_eq!(
1203+
subscribers,
1204+
vec![SubscriberAccountAndScopes { account, scope }]
1205+
);
1206+
}
1207+
11131208
async fn is_port_available(port: u16) -> bool {
11141209
TcpListener::bind(SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, port))
11151210
.await
@@ -1375,98 +1470,3 @@ async fn test_get_subscribers_v1(notify_server: &NotifyServerContext) {
13751470
vec![SubscriberAccountAndScopes { account, scope }]
13761471
);
13771472
}
1378-
1379-
#[tokio::test]
1380-
async fn test_get_subscriber_accounts_by_project_id() {
1381-
let (_, postgres) = get_dbs().await;
1382-
1383-
let project_id = ProjectId::generate();
1384-
let app_domain = &generate_app_domain();
1385-
let topic = Topic::generate();
1386-
let (signing_secret, signing_public) = generate_signing_keys();
1387-
let (authentication_secret, authentication_public) = generate_authentication_keys();
1388-
upsert_project(
1389-
project_id.clone(),
1390-
app_domain,
1391-
topic,
1392-
authentication_public,
1393-
authentication_secret,
1394-
signing_public,
1395-
signing_secret,
1396-
&postgres,
1397-
)
1398-
.await
1399-
.unwrap();
1400-
let project = get_project_by_project_id(project_id.clone(), &postgres)
1401-
.await
1402-
.unwrap();
1403-
1404-
let account = generate_account_id();
1405-
let scope = HashSet::from(["scope1".to_string(), "scope2".to_string()]);
1406-
let notify_key = rand::Rng::gen::<[u8; 32]>(&mut rand::thread_rng());
1407-
let notify_topic = sha256::digest(&notify_key).into();
1408-
upsert_subscriber(
1409-
project.id,
1410-
account.clone(),
1411-
scope,
1412-
&notify_key,
1413-
notify_topic,
1414-
&postgres,
1415-
)
1416-
.await
1417-
.unwrap();
1418-
1419-
let accounts = get_subscriber_accounts_by_project_id(project_id, &postgres)
1420-
.await
1421-
.unwrap();
1422-
assert_eq!(accounts, vec![account]);
1423-
}
1424-
1425-
#[tokio::test]
1426-
async fn test_get_subscriber_accounts_and_scopes_by_project_id() {
1427-
let (_, postgres) = get_dbs().await;
1428-
1429-
let project_id = ProjectId::generate();
1430-
let app_domain = &generate_app_domain();
1431-
let topic = Topic::generate();
1432-
let (signing_secret, signing_public) = generate_signing_keys();
1433-
let (authentication_secret, authentication_public) = generate_authentication_keys();
1434-
upsert_project(
1435-
project_id.clone(),
1436-
app_domain,
1437-
topic,
1438-
authentication_public,
1439-
authentication_secret,
1440-
signing_public,
1441-
signing_secret,
1442-
&postgres,
1443-
)
1444-
.await
1445-
.unwrap();
1446-
let project = get_project_by_project_id(project_id.clone(), &postgres)
1447-
.await
1448-
.unwrap();
1449-
1450-
let account = generate_account_id();
1451-
let scope = HashSet::from(["scope1".to_string(), "scope2".to_string()]);
1452-
let notify_key = rand::Rng::gen::<[u8; 32]>(&mut rand::thread_rng());
1453-
let notify_topic = sha256::digest(&notify_key).into();
1454-
upsert_subscriber(
1455-
project.id,
1456-
account.clone(),
1457-
scope.clone(),
1458-
&notify_key,
1459-
notify_topic,
1460-
&postgres,
1461-
)
1462-
.await
1463-
.unwrap();
1464-
1465-
let subscribers = get_subscriber_accounts_and_scopes_by_project_id(project_id, &postgres)
1466-
.await
1467-
.unwrap();
1468-
assert_eq!(
1469-
subscribers,
1470-
vec![SubscriberAccountAndScopes { account, scope }]
1471-
);
1472-
}

0 commit comments

Comments
 (0)