Debug builds now provides dummy posts

This commit is contained in:
Imbus 2023-11-15 11:32:57 +01:00
parent 686afb979c
commit 6b81763259
4 changed files with 36 additions and 0 deletions

View file

@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "INSERT INTO posts (user_id, content) VALUES (1, $1)",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text"
]
},
"nullable": []
},
"hash": "a700af019c69280cb9a0d199cc59a751a0ce16ccf2d94950219505764cc176e9"
}

11
server/Cargo.lock generated
View file

@ -1228,6 +1228,16 @@ version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829"
[[package]]
name = "lipsum"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c5e9ef2d2ad6fe67a59ace27c203c8d3a71d195532ee82e3bbe0d5f9a9ca541"
dependencies = [
"rand",
"rand_chacha",
]
[[package]] [[package]]
name = "local-channel" name = "local-channel"
version = "0.1.5" version = "0.1.5"
@ -1839,6 +1849,7 @@ dependencies = [
"dotenvy", "dotenvy",
"env_logger", "env_logger",
"jsonwebtoken", "jsonwebtoken",
"lipsum",
"log", "log",
"serde", "serde",
"serde_json", "serde_json",

View file

@ -15,6 +15,7 @@ clap = { version = "4.4.5", features = ["derive"] }
dotenvy = "0.15.7" dotenvy = "0.15.7"
env_logger = "0.10.0" env_logger = "0.10.0"
jsonwebtoken = "8.3.0" jsonwebtoken = "8.3.0"
lipsum = "0.9.0"
log = "0.4.20" log = "0.4.20"
serde = { version = "1.0.188", features = ["derive"] } serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107" serde_json = "1.0.107"

View file

@ -61,6 +61,7 @@ impl ServerState {
// Mostly useful for debugging new posts, as we need to satisfy foreign key constraints. // Mostly useful for debugging new posts, as we need to satisfy foreign key constraints.
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
async fn debug_setup(pool: &PgPool) -> Result<(), sqlx::Error> { async fn debug_setup(pool: &PgPool) -> Result<(), sqlx::Error> {
use lipsum::lipsum;
use sqlx::query; use sqlx::query;
use crate::db::db_new_user; use crate::db::db_new_user;
@ -79,6 +80,15 @@ async fn debug_setup(pool: &PgPool) -> Result<(), sqlx::Error> {
query!("INSERT INTO posts (user_id, content) VALUES (1, 'Hello world! The demo username is user and the password is pass.')",) query!("INSERT INTO posts (user_id, content) VALUES (1, 'Hello world! The demo username is user and the password is pass.')",)
.execute(pool) .execute(pool)
.await?; .await?;
for _ in 0..10 {
query!(
"INSERT INTO posts (user_id, content) VALUES (1, $1)",
lipsum(50)
)
.execute(pool)
.await?;
}
} }
Ok(()) Ok(())