Skip to content

Commit

Permalink
fix(socketio/io): add test for get_socket_by_sid
Browse files Browse the repository at this point in the history
  • Loading branch information
Totodore committed Dec 21, 2023
1 parent d152536 commit 41144f4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion socketioxide/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,9 +783,20 @@ mod tests {

#[test]
fn get_socket_by_sid() {
use engineioxide::Socket;
let sid = Sid::new();
let (_, io) = SocketIo::builder().build_svc();
io.ns("/", || {});
assert!(io.get_socket(Sid::new()).is_err());

let socket = Socket::new_dummy(sid, Box::new(|_, _| {})).into();
let config = SocketIoConfig::default().into();
io.0.get_ns("/")
.unwrap()
.connect(sid, socket, None, config)
.unwrap();

assert!(io.get_socket(sid).is_some());
assert!(io.get_socket(Sid::new()).is_none());
}

#[test]
Expand Down

0 comments on commit 41144f4

Please sign in to comment.