Skip to content

Commit

Permalink
Fix fmt issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ogzhanolguncu committed Sep 12, 2023
1 parent 84c1513 commit 091c0f4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
24 changes: 18 additions & 6 deletions src/connection_manager/command_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,15 @@ mod tests {
#[test]
fn should_return_existing_values() {
let cache = Cache::new();
cache.set("name".to_string(), "name_val".to_string()).unwrap();
cache.set("name1".to_string(), "name_val_1".to_string()).unwrap();
cache.set("name2".to_string(), "name_val_2".to_string()).unwrap();
cache
.set("name".to_string(), "name_val".to_string())
.unwrap();
cache
.set("name1".to_string(), "name_val_1".to_string())
.unwrap();
cache
.set("name2".to_string(), "name_val_2".to_string())
.unwrap();
let input =
Cow::Borrowed("*4\r\n$6\r\nexists\r\n$4\r\nname\r\n$5\r\nname1\r\n$5\r\nname2\r\n");
assert_eq!(
Expand All @@ -187,9 +193,15 @@ mod tests {
#[test]
fn should_del_values() {
let cache = Cache::new();
cache.set("name".to_string(), "name_val".to_string()).unwrap();
cache.set("name1".to_string(), "name_val_1".to_string()).unwrap();
cache.set("name2".to_string(), "name_val_2".to_string()).unwrap();
cache
.set("name".to_string(), "name_val".to_string())
.unwrap();
cache
.set("name1".to_string(), "name_val_1".to_string())
.unwrap();
cache
.set("name2".to_string(), "name_val_2".to_string())
.unwrap();
let input =
Cow::Borrowed("*4\r\n$3\r\ndel\r\n$4\r\nname\r\n$5\r\nname1\r\n$5\r\nname2\r\n");
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/resp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod deserialize;
mod error;
mod resp_parsing_utils;
pub mod serialize;
pub mod serialize;
16 changes: 10 additions & 6 deletions src/store/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,22 @@ mod tests {
#[test]
fn should_initialize_and_get_set() {
let cache = Cache::new();
cache.set(String::from("name"), String::from("The Wizard of Oz")).unwrap();
cache
.set(String::from("name"), String::from("The Wizard of Oz"))
.unwrap();
assert_eq!("The Wizard of Oz", cache.get("name").unwrap().unwrap());
}

#[test]
fn should_set_and_get_expiration() {
let cache = Cache::new();
cache.set_with_expiration(
String::from("name"),
String::from("The Wizard of Oz"),
Duration::from_secs(3),
).unwrap();
cache
.set_with_expiration(
String::from("name"),
String::from("The Wizard of Oz"),
Duration::from_secs(3),
)
.unwrap();
thread::sleep(Duration::from_secs(4));
assert!(cache.get("name").unwrap().is_none());
}
Expand Down

0 comments on commit 091c0f4

Please sign in to comment.