From af1a60665acc524c9bfde356cabd51345bda8c07 Mon Sep 17 00:00:00 2001 From: Jeff Baskin Date: Sun, 5 Feb 2023 11:32:30 -0500 Subject: [PATCH] Removed the commented code. --- src/morethantext/databases.rs | 84 ----------------------------------- 1 file changed, 84 deletions(-) diff --git a/src/morethantext/databases.rs b/src/morethantext/databases.rs index 57f327c..8fd4b36 100644 --- a/src/morethantext/databases.rs +++ b/src/morethantext/databases.rs @@ -20,29 +20,6 @@ impl Databases { } Ok(()) } - - /* - fn add_database(&mut self, name: &str, id: &str) -> Result { - if name.len() == 0 { - return Err(DBError::new("database names cannot be empty")); - } else if self.db_map.contains_key(name) { - return Err(DBError::new("database already exists")); - } else { - self.db_map.insert(name.to_string(), id.to_string()); - Ok(id.to_string()) - } - } - - fn get_database(&self, name: &str) -> Option { - self.db_map.get(name).cloned() - } - - fn show(&self) -> Vec { - let mut names: Vec = self.db_map.clone().into_keys().collect(); - names.sort(); - names - } - */ } impl FileData for Databases { @@ -145,67 +122,6 @@ impl SessionData for Databases { } } -/* -#[cfg(test)] -mod functions { - use super::*; - - #[test] - fn add_entry() { - let name = "fred"; - let id = "123456"; - let mut dbs = Databases::new(); - let output = dbs.add_database(name, id).unwrap(); - assert_eq!(output, id.to_string()); - } - - #[test] - fn add_entry_no_name() { - let name = ""; - let id = "123456"; - let mut dbs = Databases::new(); - match dbs.add_database(name, id) { - Ok(_) => assert!(false, "There should have been an error"), - Err(err) => assert_eq!(err.to_string(), "database names cannot be empty"), - } - } - - #[test] - fn entry_cannot_be_over_written() { - let name = "barney"; - let id = "abcde"; - let mut dbs = Databases::new(); - dbs.add_database(name, id).unwrap(); - match dbs.add_database(name, "09876") { - Ok(_) => assert!(false, "There should have been an error"), - Err(err) => assert_eq!(err.to_string(), "database already exists"), - } - let output = dbs.get_database(name); - assert_eq!(output, Some(id.to_string())); - } - - #[test] - fn get_bad_database() { - let dbs = Databases::new(); - let output = dbs.get_database("missing"); - assert_eq!(output, None); - } - - #[test] - fn list_databases() { - let mut dbs = Databases::new(); - dbs.add_database("zebra", "a").unwrap(); - dbs.add_database("alpha", "a").unwrap(); - dbs.add_database("charlie", "a").unwrap(); - dbs.add_database("wilma", "a").unwrap(); - dbs.add_database("frank", "a").unwrap(); - let expected = ["alpha", "charlie", "frank", "wilma", "zebra"]; - let output = dbs.show(); - assert_eq!(output, expected); - } -} -*/ - #[cfg(test)] mod file_data { use super::*;