Merge branch 'main' into reconnections-2

This commit is contained in:
Antonio Scandurra 2022-12-02 19:09:33 +01:00
commit 969c314315
78 changed files with 2759 additions and 1281 deletions

View file

@ -667,19 +667,29 @@ async fn test_signups() {
let test_db = TestDb::postgres(build_background_executor());
let db = test_db.db();
// people sign up on the waitlist
for i in 0..8 {
db.create_signup(NewSignup {
email_address: format!("person-{i}@example.com"),
let usernames = (0..8).map(|i| format!("person-{i}")).collect::<Vec<_>>();
let all_signups = usernames
.iter()
.enumerate()
.map(|(i, username)| NewSignup {
email_address: format!("{username}@example.com"),
platform_mac: true,
platform_linux: i % 2 == 0,
platform_windows: i % 4 == 0,
editor_features: vec!["speed".into()],
programming_languages: vec!["rust".into(), "c".into()],
device_id: Some(format!("device_id_{i}")),
added_to_mailing_list: i != 0, // One user failed to subscribe
})
.await
.unwrap();
.collect::<Vec<NewSignup>>();
// people sign up on the waitlist
for signup in &all_signups {
// users can sign up multiple times without issues
for _ in 0..2 {
db.create_signup(&signup).await.unwrap();
}
}
assert_eq!(
@ -702,9 +712,9 @@ async fn test_signups() {
assert_eq!(
addresses,
&[
"person-0@example.com",
"person-1@example.com",
"person-2@example.com"
all_signups[0].email_address.as_str(),
all_signups[1].email_address.as_str(),
all_signups[2].email_address.as_str()
]
);
assert_ne!(
@ -728,9 +738,9 @@ async fn test_signups() {
assert_eq!(
addresses,
&[
"person-3@example.com",
"person-4@example.com",
"person-5@example.com"
all_signups[3].email_address.as_str(),
all_signups[4].email_address.as_str(),
all_signups[5].email_address.as_str()
]
);
@ -756,11 +766,10 @@ async fn test_signups() {
} = db
.create_user_from_invite(
&Invite {
email_address: signups_batch1[0].email_address.clone(),
email_confirmation_code: signups_batch1[0].email_confirmation_code.clone(),
..signups_batch1[0].clone()
},
NewUserParams {
github_login: "person-0".into(),
github_login: usernames[0].clone(),
github_user_id: 0,
invite_count: 5,
},
@ -770,8 +779,11 @@ async fn test_signups() {
.unwrap();
let user = db.get_user_by_id(user_id).await.unwrap().unwrap();
assert!(inviting_user_id.is_none());
assert_eq!(user.github_login, "person-0");
assert_eq!(user.email_address.as_deref(), Some("person-0@example.com"));
assert_eq!(user.github_login, usernames[0]);
assert_eq!(
user.email_address,
Some(all_signups[0].email_address.clone())
);
assert_eq!(user.invite_count, 5);
assert_eq!(signup_device_id.unwrap(), "device_id_0");
@ -799,7 +811,7 @@ async fn test_signups() {
email_confirmation_code: "the-wrong-code".to_string(),
},
NewUserParams {
github_login: "person-1".into(),
github_login: usernames[1].clone(),
github_user_id: 2,
invite_count: 5,
},