Write unit tests and fix various bugs

This commit is contained in:
Kiana Sheibani 2023-10-05 01:47:09 -04:00
parent 2e3bd017f3
commit 473b9c60a6
Signed by: toki
GPG key ID: 6CB106C25E86A9F7
6 changed files with 299 additions and 78 deletions

View file

@ -227,8 +227,8 @@ fn sync(datasets: Vec<String>, all: bool, auth_token: Option<String>) {
#[allow(unused_must_use)]
let datasets = if all {
all_datasets
} else if datasets.len() == 0 {
if all_datasets.len() == 0 {
} else if datasets.is_empty() {
if all_datasets.is_empty() {
print!("No datasets exist; create one? (y/n) ");
if let Some('y') = read_string().chars().next() {
dataset_new(Some(String::from("default")), Some(auth.clone()));
@ -250,10 +250,8 @@ fn sync(datasets: Vec<String>, all: bool, auth_token: Option<String>) {
.expect("Error communicating with SQLite")
.unwrap_or_else(|| error(&format!("Dataset {} does not exist!", dataset), 1));
sync_dataset(&connection, &dataset, dataset_config, &auth).unwrap_or_else(|_| {
connection.execute("ROLLBACK;").unwrap();
error("Error communicating with SQLite", 2)
});
sync_dataset(&connection, &dataset, dataset_config, &auth)
.unwrap_or_else(|_| error("Error communicating with SQLite", 2));
update_last_sync(&connection, &dataset).expect("Error communicating with SQLite");
}