forked from lavina/lavina
Test chathistory
This commit is contained in:
parent
1e8a183d6c
commit
2ffe3ba197
|
@ -104,6 +104,7 @@ struct TestServer {
|
||||||
core: LavinaCore,
|
core: LavinaCore,
|
||||||
server: RunningServer,
|
server: RunningServer,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestServer {
|
impl TestServer {
|
||||||
async fn start() -> Result<TestServer> {
|
async fn start() -> Result<TestServer> {
|
||||||
let _ = tracing_subscriber::fmt::try_init();
|
let _ = tracing_subscriber::fmt::try_init();
|
||||||
|
@ -187,6 +188,46 @@ async fn scenario_basic() -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn scenario_basic_with_chathistory() -> Result<()> {
|
||||||
|
let server = TestServer::start().await?;
|
||||||
|
|
||||||
|
// test scenario
|
||||||
|
|
||||||
|
server.core.create_player(&PlayerId::from("tester")?).await?;
|
||||||
|
server.core.set_password("tester", "password").await?;
|
||||||
|
|
||||||
|
let mut stream = TcpStream::connect(server.server.addr).await?;
|
||||||
|
let mut s = TestScope::new(&mut stream);
|
||||||
|
|
||||||
|
s.send("PASS password").await?;
|
||||||
|
s.send("NICK tester").await?;
|
||||||
|
s.send("USER UserName 0 * :Real Name").await?;
|
||||||
|
s.expect_server_introduction("tester").await?;
|
||||||
|
s.expect_nothing().await?;
|
||||||
|
|
||||||
|
s.send("JOIN #test").await?;
|
||||||
|
s.expect(":tester JOIN #test").await?;
|
||||||
|
s.expect(":testserver 332 tester #test :New room").await?;
|
||||||
|
s.expect(":testserver 353 tester = #test :tester").await?;
|
||||||
|
s.expect(":testserver 366 tester #test :End of /NAMES list").await?;
|
||||||
|
s.send("PRIVMSG #test :Hello").await?;
|
||||||
|
|
||||||
|
s.send("CHATHISTORY LATEST #test * 100").await?;
|
||||||
|
s.expect(":tester PRIVMSG #test :Hello").await?;
|
||||||
|
|
||||||
|
s.send("QUIT :Leaving").await?;
|
||||||
|
s.expect(":testserver ERROR :Leaving the server").await?;
|
||||||
|
s.expect_eof().await?;
|
||||||
|
|
||||||
|
stream.shutdown().await?;
|
||||||
|
|
||||||
|
// wrap up
|
||||||
|
|
||||||
|
server.shutdown().await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn scenario_join_and_reboot() -> Result<()> {
|
async fn scenario_join_and_reboot() -> Result<()> {
|
||||||
let server = TestServer::start().await?;
|
let server = TestServer::start().await?;
|
||||||
|
|
Loading…
Reference in New Issue