Removed the commented code.
This commit is contained in:
parent
5b291e3553
commit
af1a60665a
@ -20,29 +20,6 @@ impl Databases {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/*
|
||||
fn add_database(&mut self, name: &str, id: &str) -> Result<String, DBError> {
|
||||
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<String> {
|
||||
self.db_map.get(name).cloned()
|
||||
}
|
||||
|
||||
fn show(&self) -> Vec<String> {
|
||||
let mut names: Vec<String> = self.db_map.clone().into_keys().collect();
|
||||
names.sort();
|
||||
names
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
impl FileData<Self> 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::*;
|
||||
|
Loading…
Reference in New Issue
Block a user