Skip to content

Commit 8212f56

Browse files
committed
Use NEXT_GH_ID rather than setting gh_id to 1 in multiple tests
1 parent b4c4a88 commit 8212f56

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/tests/user.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,7 @@ fn test_github_login_does_not_overwrite_email() {
270270
let mut req = req(Method::Get, "/api/v1/me");
271271
let user = {
272272
let conn = app.diesel_database.get().unwrap();
273-
let user = NewUser {
274-
gh_id: 1,
275-
..new_user("apricot")
276-
};
273+
let user = new_user("apricot");
277274

278275
let user = user.create_or_update(&conn).unwrap();
279276
sign_in_as(&mut req, &user);
@@ -299,7 +296,7 @@ fn test_github_login_does_not_overwrite_email() {
299296
{
300297
let conn = app.diesel_database.get().unwrap();
301298
let user = NewUser {
302-
gh_id: 1,
299+
gh_id: user.gh_id,
303300
..new_user("apricot")
304301
};
305302

@@ -449,17 +446,17 @@ fn test_this_user_cannot_change_that_user_email() {
449446
fn test_insert_into_email_table() {
450447
let (_b, app, middle) = app();
451448
let mut req = req(Method::Get, "/me");
452-
{
449+
let user = {
453450
let conn = app.diesel_database.get().unwrap();
454451
let user = NewUser {
455-
gh_id: 1,
456452
email: Some("[email protected]"),
457453
..new_user("apple")
458454
};
459455

460456
let user = user.create_or_update(&conn).unwrap();
461457
sign_in_as(&mut req, &user);
462-
}
458+
user
459+
};
463460

464461
let mut response = ok_resp!(middle.call(req.with_path("/api/v1/me").with_method(Method::Get),));
465462
let r = crate::json::<UserShowPrivateResponse>(&mut response);
@@ -472,7 +469,7 @@ fn test_insert_into_email_table() {
472469
{
473470
let conn = app.diesel_database.get().unwrap();
474471
let user = NewUser {
475-
gh_id: 1,
472+
gh_id: user.gh_id,
476473
email: Some("[email protected]"),
477474
..new_user("apple")
478475
};
@@ -499,7 +496,6 @@ fn test_insert_into_email_table_with_email_change() {
499496
let user = {
500497
let conn = app.diesel_database.get().unwrap();
501498
let user = NewUser {
502-
gh_id: 1,
503499
email: Some("[email protected]"),
504500
..new_user("potato")
505501
};
@@ -531,7 +527,7 @@ fn test_insert_into_email_table_with_email_change() {
531527
{
532528
let conn = app.diesel_database.get().unwrap();
533529
let user = NewUser {
534-
gh_id: 1,
530+
gh_id: user.gh_id,
535531
email: Some("[email protected]"),
536532
..new_user("potato")
537533
};

0 commit comments

Comments
 (0)