From 296fde99544a57081b39f18907abefca2430c30e Mon Sep 17 00:00:00 2001 From: shockrah Date: Thu, 20 Aug 2020 19:20:21 -0700 Subject: [PATCH] new helper function to generate channel parametesr for generating chanels --- server/src/testing/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/src/testing/mod.rs b/server/src/testing/mod.rs index 8a751b8..31cdd81 100644 --- a/server/src/testing/mod.rs +++ b/server/src/testing/mod.rs @@ -17,3 +17,22 @@ pub fn hyper_resp() -> hyper::Response { Response::new(Body::empty()) } + + +#[cfg(test)] +pub async fn tmp_channel_params(p: &mysql_async::Pool, chan_name: &'static str) -> crate::channels::Channel { + use crate::channels::{Channel, ChannelType}; + use mysql_async::{params, prelude::Queryable}; + + let conn = p.get_conn().await.unwrap(); + let _ = conn.prep_exec( + "INSERT INTO channels (name, description, kind) VALUES (:name, :description, :kind)", + params!{"name" => chan_name, "kind" => 0, "description" => "no description for testing"}).await; + + Channel { + id: 0, + name: chan_name.into(), + kind: ChannelType::Text, + description: "no description for testing".into() + } +}