mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Ensure that subsequent signup happens after initial
We can't rely on the fact that the test won't run fast enough such that both `created_at`s are the same time. This ensures the subsequent signup happens after the initial one and that the database doesn't overwrite the initial one.
This commit is contained in:
parent
5f31907127
commit
d71d543337
2 changed files with 14 additions and 0 deletions
|
@ -44,6 +44,7 @@ pub struct NewSignup {
|
|||
pub programming_languages: Vec<String>,
|
||||
pub device_id: Option<String>,
|
||||
pub added_to_mailing_list: bool,
|
||||
pub created_at: Option<DateTime>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, FromQueryResult)]
|
||||
|
|
|
@ -737,6 +737,8 @@ async fn test_multiple_signup_overwrite() {
|
|||
|
||||
let email_address = "user_1@example.com".to_string();
|
||||
|
||||
let initial_signup_created_at_milliseconds = 0;
|
||||
|
||||
let initial_signup = NewSignup {
|
||||
email_address: email_address.clone(),
|
||||
platform_mac: false,
|
||||
|
@ -746,6 +748,9 @@ async fn test_multiple_signup_overwrite() {
|
|||
programming_languages: vec!["rust".into(), "c".into()],
|
||||
device_id: Some(format!("device_id")),
|
||||
added_to_mailing_list: false,
|
||||
created_at: Some(
|
||||
DateTime::from_timestamp_millis(initial_signup_created_at_milliseconds).unwrap(),
|
||||
),
|
||||
};
|
||||
|
||||
db.create_signup(&initial_signup).await.unwrap();
|
||||
|
@ -775,6 +780,13 @@ async fn test_multiple_signup_overwrite() {
|
|||
programming_languages: vec!["d".into(), "elm".into()],
|
||||
device_id: Some(format!("different_device_id")),
|
||||
added_to_mailing_list: true,
|
||||
// subsequent signup happens next day
|
||||
created_at: Some(
|
||||
DateTime::from_timestamp_millis(
|
||||
initial_signup_created_at_milliseconds + (1000 * 60 * 60 * 24),
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
};
|
||||
|
||||
db.create_signup(&subsequent_signup).await.unwrap();
|
||||
|
@ -817,6 +829,7 @@ async fn test_signups() {
|
|||
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
|
||||
created_at: Some(DateTime::from_timestamp_millis(i as i64).unwrap()), // Signups are consecutive
|
||||
})
|
||||
.collect::<Vec<NewSignup>>();
|
||||
|
||||
|
|
Loading…
Reference in a new issue