diff --git a/tests/pg_sql/util.rs b/tests/pg_sql/util.rs index 6ce5fb84..848217b7 100644 --- a/tests/pg_sql/util.rs +++ b/tests/pg_sql/util.rs @@ -9,11 +9,13 @@ pub async fn setup_db(pool: &PgPool) -> anyhow::Result<()> { // migration scripts. sqlx::query(r#"create schema auth"#).execute(pool).await?; sqlx::query( - r#"create table auth.users( -id uuid NOT NULL UNIQUE, -deleted_at timestamptz null, -CONSTRAINT users_pkey PRIMARY KEY (id) -)"#, + r#" + CREATE TABLE auth.users( + id uuid NOT NULL UNIQUE, + deleted_at timestamptz null, + CONSTRAINT users_pkey PRIMARY KEY (id) + ) + "#, ) .execute(pool) .await?; @@ -26,6 +28,19 @@ CONSTRAINT users_pkey PRIMARY KEY (id) Ok(()) } +pub async fn insert_auth_user(pool: &PgPool, user_uuid: Uuid) -> anyhow::Result<()> { + sqlx::query( + r#" + INSERT INTO auth.users (id) + VALUES ($1) + "#, + ) + .bind(user_uuid) + .execute(pool) + .await?; + Ok(()) +} + lazy_static! { pub static ref ID_GEN: RwLock = RwLock::new(Snowflake::new(1)); } diff --git a/tests/pg_sql/workspace_test.rs b/tests/pg_sql/workspace_test.rs index e56143de..e7a066a3 100644 --- a/tests/pg_sql/workspace_test.rs +++ b/tests/pg_sql/workspace_test.rs @@ -1,4 +1,4 @@ -use crate::pg_sql::util::{setup_db, test_create_user}; +use crate::pg_sql::util::{insert_auth_user, setup_db, test_create_user}; use sqlx::PgPool; #[sqlx::test(migrations = false)] @@ -9,6 +9,7 @@ async fn basic_test(pool: PgPool) -> sqlx::Result<()> { let name = user_uuid.to_string(); let email = format!("{}@appflowy.io", name); + insert_auth_user(&pool, user_uuid).await.unwrap(); test_create_user(&pool, user_uuid, &email, &name) .await .unwrap();