From 78f4cc39658352111c9f900693a20816518d06ae Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 11 Feb 2023 10:47:19 -0600 Subject: [PATCH] Fix errors in tests --- src/message.rs | 14 ++------------ src/server/broadcast.rs | 6 +++--- src/server/listen.rs | 2 +- src/server/mod.rs | 6 +++--- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/message.rs b/src/message.rs index 6fdc892..bdbd64d 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,4 +1,4 @@ -use crate::asciicast::{Event, EventKind, Header, HeaderBuilder}; +use crate::asciicast::{Event, Header}; /// Message used by Liveterm for broadcasts #[derive(Clone, Debug, Serialize, Deserialize)] @@ -15,18 +15,8 @@ pub struct ServerHello { #[test] fn test() { - let msg = Message::AsciicastHeader( - HeaderBuilder::default() - .width(30) - .height(30) - .build() - .unwrap(), - ); - println!("{}", serde_json::to_string(&msg).unwrap()); -} + use crate::asciicast::EventKind; -#[test] -fn test2() { const msg: &'static str = "{\"AsciicastEvent\":[0.058985141,\"o\",\"\\u001b[1m\\u001b[3m%\\u001b[23m\\u001b[1m\\u001b[0m \\r \\r\"]}"; let msg2: Message = serde_json::from_str(&msg).unwrap(); if let Message::AsciicastEvent(ref evt) = msg2 { diff --git a/src/server/broadcast.rs b/src/server/broadcast.rs index ce0ba14..cdd03cf 100644 --- a/src/server/broadcast.rs +++ b/src/server/broadcast.rs @@ -12,10 +12,10 @@ use dashmap::{mapref::entry::Entry, DashMap}; use futures::{future::BoxFuture, FutureExt}; use rand::{prelude::Distribution, Rng}; use serde::Deserialize; -use tokio::sync::broadcast::{self, Receiver, Sender}; +use tokio::sync::broadcast::{self, Sender}; use crate::{ - asciicast::{Event, Header}, + asciicast::{Header}, message::{Message, ServerHello}, }; @@ -89,7 +89,7 @@ async fn handle_websocket_inner( Some(v) => deserialize_message(&v?)?, None => bail!("send a header please..."), }; - let header: Header = match msg { + let _header: Header = match msg { Message::AsciicastHeader(header) => header, _ => bail!("please send header omg!!!"), }; diff --git a/src/server/listen.rs b/src/server/listen.rs index ade281e..8504db8 100644 --- a/src/server/listen.rs +++ b/src/server/listen.rs @@ -1,4 +1,4 @@ -use anyhow::{Context, Result}; +use anyhow::{Result}; use axum::{ extract::{ ws::{Message as WsMessage, WebSocket}, diff --git a/src/server/mod.rs b/src/server/mod.rs index f4dff4c..a19d446 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -6,10 +6,10 @@ use std::net::SocketAddr; use anyhow::Result; use axum::{ - extract::{Path, WebSocketUpgrade}, - http::{Response, StatusCode}, + extract::{Path}, + http::{StatusCode}, response::Html, - routing::{get, post}, + routing::{get}, Router, }; use tera::{Context, Tera};