forked from lavina/lavina
Compare commits
2 Commits
1e8a183d6c
...
7efbea7b71
Author | SHA1 | Date |
---|---|---|
Mikhail | 7efbea7b71 | |
Mikhail | 2ffe3ba197 |
|
@ -104,6 +104,7 @@ struct TestServer {
|
|||
core: LavinaCore,
|
||||
server: RunningServer,
|
||||
}
|
||||
|
||||
impl TestServer {
|
||||
async fn start() -> Result<TestServer> {
|
||||
let _ = tracing_subscriber::fmt::try_init();
|
||||
|
@ -187,6 +188,55 @@ async fn scenario_basic() -> Result<()> {
|
|||
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 :Message1").await?;
|
||||
s.send("PRIVMSG #test :Message2").await?;
|
||||
s.send("PRIVMSG #test :Message3").await?;
|
||||
s.send("PRIVMSG #test :Message4").await?;
|
||||
|
||||
s.send("CHATHISTORY LATEST #test * 1").await?;
|
||||
s.expect(":tester PRIVMSG #test :Message4").await?;
|
||||
|
||||
s.send("CHATHISTORY LATEST #test * 3").await?;
|
||||
s.expect(":tester PRIVMSG #test :Message2").await?;
|
||||
s.expect(":tester PRIVMSG #test :Message3").await?;
|
||||
s.expect(":tester PRIVMSG #test :Message4").await?;
|
||||
s.expect_nothing().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]
|
||||
async fn scenario_join_and_reboot() -> Result<()> {
|
||||
let server = TestServer::start().await?;
|
||||
|
|
Loading…
Reference in New Issue