Fix errors in tests
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
032946978c
commit
78f4cc3965
4 changed files with 9 additions and 19 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::asciicast::{Event, EventKind, Header, HeaderBuilder};
|
use crate::asciicast::{Event, Header};
|
||||||
|
|
||||||
/// Message used by Liveterm for broadcasts
|
/// Message used by Liveterm for broadcasts
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
@ -15,18 +15,8 @@ pub struct ServerHello {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test() {
|
fn test() {
|
||||||
let msg = Message::AsciicastHeader(
|
use crate::asciicast::EventKind;
|
||||||
HeaderBuilder::default()
|
|
||||||
.width(30)
|
|
||||||
.height(30)
|
|
||||||
.build()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
println!("{}", serde_json::to_string(&msg).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test2() {
|
|
||||||
const msg: &'static str = "{\"AsciicastEvent\":[0.058985141,\"o\",\"\\u001b[1m\\u001b[3m%\\u001b[23m\\u001b[1m\\u001b[0m \\r \\r\"]}";
|
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();
|
let msg2: Message = serde_json::from_str(&msg).unwrap();
|
||||||
if let Message::AsciicastEvent(ref evt) = msg2 {
|
if let Message::AsciicastEvent(ref evt) = msg2 {
|
||||||
|
|
|
@ -12,10 +12,10 @@ use dashmap::{mapref::entry::Entry, DashMap};
|
||||||
use futures::{future::BoxFuture, FutureExt};
|
use futures::{future::BoxFuture, FutureExt};
|
||||||
use rand::{prelude::Distribution, Rng};
|
use rand::{prelude::Distribution, Rng};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tokio::sync::broadcast::{self, Receiver, Sender};
|
use tokio::sync::broadcast::{self, Sender};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
asciicast::{Event, Header},
|
asciicast::{Header},
|
||||||
message::{Message, ServerHello},
|
message::{Message, ServerHello},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ async fn handle_websocket_inner(
|
||||||
Some(v) => deserialize_message(&v?)?,
|
Some(v) => deserialize_message(&v?)?,
|
||||||
None => bail!("send a header please..."),
|
None => bail!("send a header please..."),
|
||||||
};
|
};
|
||||||
let header: Header = match msg {
|
let _header: Header = match msg {
|
||||||
Message::AsciicastHeader(header) => header,
|
Message::AsciicastHeader(header) => header,
|
||||||
_ => bail!("please send header omg!!!"),
|
_ => bail!("please send header omg!!!"),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Result};
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{
|
extract::{
|
||||||
ws::{Message as WsMessage, WebSocket},
|
ws::{Message as WsMessage, WebSocket},
|
||||||
|
|
|
@ -6,10 +6,10 @@ use std::net::SocketAddr;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Path, WebSocketUpgrade},
|
extract::{Path},
|
||||||
http::{Response, StatusCode},
|
http::{StatusCode},
|
||||||
response::Html,
|
response::Html,
|
||||||
routing::{get, post},
|
routing::{get},
|
||||||
Router,
|
Router,
|
||||||
};
|
};
|
||||||
use tera::{Context, Tera};
|
use tera::{Context, Tera};
|
||||||
|
|
Loading…
Reference in a new issue