channel deletion seems to pass basic unit tests
This commit is contained in:
parent
362eb53650
commit
34a04f7887
@ -162,9 +162,10 @@ fn parse_insert_channel_params(name_r: Option<&Value>, kind_r: Option<&Value>) -
|
||||
(Some(name), Some(kind)) => {
|
||||
|
||||
let channel = InsertableChannel {
|
||||
name: name.to_string(),
|
||||
name: name.as_str().unwrap().into(), // as_str removes the quotes from the output
|
||||
kind: ChannelType::from_i64_opt(kind.as_i64()),
|
||||
};
|
||||
println!("Insertable channel name: {}", channel.name);
|
||||
Ok(channel)
|
||||
}
|
||||
_ => {
|
||||
@ -177,7 +178,7 @@ async fn insert_channel(pool: &Pool, channel: InsertableChannel) -> Result<(), D
|
||||
if let Ok(conn) = pool.get_conn().await {
|
||||
let db_result: Result<Conn, Error> = conn.drop_exec(
|
||||
"INSERT INTO channels (name, kind) VALUES (:name, 0)",
|
||||
mysql_async::params!{ "name" => channel.name }
|
||||
params!{"name" => channel.name}
|
||||
).await;
|
||||
match db_result {
|
||||
Ok(_) => Ok(()),
|
||||
@ -221,11 +222,10 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
|
||||
async fn db_delete_channel(pool: &Pool, name: &Value) -> Result<(), Error> {
|
||||
let conn = pool.get_conn().await?;
|
||||
let q = "DELETE FROM channels WHERE name = :name";
|
||||
let p = params!{ "name" => name.as_str().unwrap() };
|
||||
conn.batch_exec(q, p).await?;
|
||||
conn.prep_exec(r"DELETE FROM channels WHERE name = :name", params!{"name" => name.as_str().unwrap()}).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn delete_channel(pool: &Pool, response: &mut Response<Body>, params: Value) {
|
||||
// make sure we have the right parameters provided
|
||||
if let Some(name) = params.get("name") {
|
||||
|
Loading…
Reference in New Issue
Block a user