Browse Source

Get rid of Error::description()

master
Adrian Heine 2 years ago
parent
commit
d3236903fc
  1. 8
      src/schema.rs
  2. 18
      tests/storage.rs

8
src/schema.rs

@ -22,12 +22,6 @@ pub enum SymbolRunError {
}
impl Error for SymbolRunError {
fn description(&self) -> &str {
match self {
Self::Symbol(_) => "Symbol execution error",
Self::ExecuteDidNotReach(_) => "Target not reached after executing symbol",
}
}
fn cause(&self) -> Option<&dyn Error> {
match self {
Self::Symbol(ref e) => Some(&**e),
@ -40,7 +34,7 @@ impl fmt::Display for SymbolRunError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Symbol(ref e) => write!(f, "{}", e),
Self::ExecuteDidNotReach(_) => write!(f, "{}", self.description()),
Self::ExecuteDidNotReach(_) => write!(f, "Target not reached after executing symbol"),
}
}
}

18
tests/storage.rs

@ -103,12 +103,12 @@ fn empty_storage() {
);
assert!(storage.read_filename().is_err());
assert_eq!(
storage.read_filename().unwrap_err().description(),
storage.read_filename().unwrap_err().to_string(),
"entity not found"
);
assert!(storage.recent_date().is_err());
assert_eq!(
storage.recent_date().unwrap_err().description(),
storage.recent_date().unwrap_err().to_string(),
"entity not found"
);
}
@ -125,14 +125,11 @@ fn empty_storage_for_filename() {
);
assert!(storage.read_filename().is_err());
assert_eq!(
storage.read_filename().unwrap_err().description(),
storage.read_filename().unwrap_err().to_string(),
"Not found"
);
assert!(storage.recent_date().is_err());
assert_eq!(
storage.recent_date().unwrap_err().description(),
"Not found"
);
assert_eq!(storage.recent_date().unwrap_err().to_string(), "Not found");
}
#[test]
@ -147,12 +144,9 @@ fn bad_file() {
);
assert!(storage.read_filename().is_err());
assert_eq!(
storage.read_filename().unwrap_err().description(),
storage.read_filename().unwrap_err().to_string(),
"Not found"
);
assert!(storage.recent_date().is_err());
assert_eq!(
storage.recent_date().unwrap_err().description(),
"Not found"
);
assert_eq!(storage.recent_date().unwrap_err().to_string(), "Not found");
}
Loading…
Cancel
Save