Add new package with methods to save and load compressor state (#63)
This commit is contained in:
@@ -69,7 +69,7 @@ pub fn add_contents_to_database(room_id: &str, state_group_map: &BTreeMap<i64, S
|
||||
client.batch_execute(&sql).unwrap();
|
||||
}
|
||||
|
||||
// Clears the contents of the testing database
|
||||
/// Clears the contents of the testing database
|
||||
pub fn empty_database() {
|
||||
// connect to the database
|
||||
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
@@ -80,9 +80,9 @@ pub fn empty_database() {
|
||||
|
||||
// delete all the contents from all three tables
|
||||
let sql = r"
|
||||
DELETE FROM state_groups;
|
||||
DELETE FROM state_group_edges;
|
||||
DELETE FROM state_groups_state;
|
||||
TRUNCATE state_groups;
|
||||
TRUNCATE state_group_edges;
|
||||
TRUNCATE state_groups_state;
|
||||
";
|
||||
|
||||
client.batch_execute(sql).unwrap();
|
||||
@@ -300,6 +300,24 @@ pub fn database_structure_matches_map(state_group_map: &BTreeMap<i64, StateGroup
|
||||
true
|
||||
}
|
||||
|
||||
/// Clears the compressor state from the database
|
||||
pub fn clear_compressor_state() {
|
||||
// connect to the database
|
||||
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
|
||||
builder.set_verify(SslVerifyMode::NONE);
|
||||
let connector = MakeTlsConnector::new(builder.build());
|
||||
|
||||
let mut client = Client::connect(DB_URL, connector).unwrap();
|
||||
|
||||
// delete all the contents from the state compressor tables
|
||||
let sql = r"
|
||||
TRUNCATE state_compressor_state;
|
||||
TRUNCATE state_compressor_progress;
|
||||
";
|
||||
|
||||
client.batch_execute(sql).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn functions_are_self_consistent() {
|
||||
let mut initial: BTreeMap<i64, StateGroupEntry> = BTreeMap::new();
|
||||
|
||||
Reference in New Issue
Block a user