use dcss_api::Webtile;
#[test]
fn write_read_rc() {
let game_id = std::env::var("GAME_ID").unwrap_or("dcss-0.33".to_owned());
let mut webtile =
Webtile::connect("ws://localhost:8080/socket", 0).expect("Failed to connect.");
while webtile.get_message().is_some() {}
webtile
.login_with_credentials("Username", "Password")
.expect("Login failed.");
while webtile.get_message().is_some() {}
webtile
.set_rc_file(game_id.as_str(), "this is a test")
.expect("Failed to write");
let rc_file = webtile
.get_rc_file(game_id.as_str())
.expect("Failed to read.");
assert_eq!("this is a test", rc_file);
while webtile.get_message().is_some() {}
webtile
.set_rc_file(game_id.as_str(), "show_more = false\nrest_delay = -1")
.expect("Failed to write");
let rc_file = webtile
.get_rc_file(game_id.as_str())
.expect("Failed to read.");
assert_eq!("show_more = false\nrest_delay = -1", rc_file);
webtile.disconnect().expect("Failed to disconnect");
}
#[test]
fn blank_rc_file() {
let game_id = std::env::var("GAME_ID").unwrap_or("dcss-0.33".to_owned());
let mut webtile =
Webtile::connect("ws://localhost:8080/socket", 0).expect("Failed to connect.");
while webtile.get_message().is_some() {}
webtile
.login_with_credentials("Username", "Password")
.expect("Login failed.");
while webtile.get_message().is_some() {}
webtile
.set_rc_file(game_id.as_str(), "")
.expect("Failed to write");
let rc_file = webtile
.get_rc_file(game_id.as_str())
.expect("Failed to read.");
assert_eq!("", rc_file);
while webtile.get_message().is_some() {}
webtile
.set_rc_file(game_id.as_str(), "show_more = false\nrest_delay = -1")
.expect("Failed to write");
let rc_file = webtile
.get_rc_file(game_id.as_str())
.expect("Failed to read.");
assert_eq!("show_more = false\nrest_delay = -1", rc_file);
webtile.disconnect().expect("Failed to disconnect");
}