Update names of collab auth functions to clarify behavior (#32648)
Release Notes: - N/A
This commit is contained in:
parent
cef0c415f6
commit
1078f929aa
7 changed files with 23 additions and 16 deletions
|
@ -71,7 +71,7 @@ impl Database {
|
|||
) -> Result<()> {
|
||||
self.weak_transaction(|tx| async move {
|
||||
let user = self
|
||||
.get_or_create_user_by_github_account_tx(
|
||||
.update_or_create_user_by_github_account_tx(
|
||||
github_login,
|
||||
github_user_id,
|
||||
github_email,
|
||||
|
|
|
@ -111,7 +111,7 @@ impl Database {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn get_or_create_user_by_github_account(
|
||||
pub async fn update_or_create_user_by_github_account(
|
||||
&self,
|
||||
github_login: &str,
|
||||
github_user_id: i32,
|
||||
|
@ -121,7 +121,7 @@ impl Database {
|
|||
initial_channel_id: Option<ChannelId>,
|
||||
) -> Result<User> {
|
||||
self.transaction(|tx| async move {
|
||||
self.get_or_create_user_by_github_account_tx(
|
||||
self.update_or_create_user_by_github_account_tx(
|
||||
github_login,
|
||||
github_user_id,
|
||||
github_email,
|
||||
|
@ -135,7 +135,7 @@ impl Database {
|
|||
.await
|
||||
}
|
||||
|
||||
pub async fn get_or_create_user_by_github_account_tx(
|
||||
pub async fn update_or_create_user_by_github_account_tx(
|
||||
&self,
|
||||
github_login: &str,
|
||||
github_user_id: i32,
|
||||
|
|
|
@ -72,12 +72,12 @@ async fn test_get_users(db: &Arc<Database>) {
|
|||
}
|
||||
|
||||
test_both_dbs!(
|
||||
test_get_or_create_user_by_github_account,
|
||||
test_get_or_create_user_by_github_account_postgres,
|
||||
test_get_or_create_user_by_github_account_sqlite
|
||||
test_update_or_create_user_by_github_account,
|
||||
test_update_or_create_user_by_github_account_postgres,
|
||||
test_update_or_create_user_by_github_account_sqlite
|
||||
);
|
||||
|
||||
async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
|
||||
async fn test_update_or_create_user_by_github_account(db: &Arc<Database>) {
|
||||
db.create_user(
|
||||
"user1@example.com",
|
||||
None,
|
||||
|
@ -104,7 +104,14 @@ async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
|
|||
.user_id;
|
||||
|
||||
let user = db
|
||||
.get_or_create_user_by_github_account("the-new-login2", 102, None, None, Utc::now(), None)
|
||||
.update_or_create_user_by_github_account(
|
||||
"the-new-login2",
|
||||
102,
|
||||
None,
|
||||
None,
|
||||
Utc::now(),
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(user.id, user_id2);
|
||||
|
@ -112,7 +119,7 @@ async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) {
|
|||
assert_eq!(user.github_user_id, 102);
|
||||
|
||||
let user = db
|
||||
.get_or_create_user_by_github_account(
|
||||
.update_or_create_user_by_github_account(
|
||||
"login3",
|
||||
103,
|
||||
Some("user3@example.com"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue