Finished out the database stub.
This commit is contained in:
		| @@ -62,6 +62,7 @@ impl CacheType { | |||||||
|                 Ok(CacheType::Raw(str::from_utf8(&output).unwrap().to_string())) |                 Ok(CacheType::Raw(str::from_utf8(&output).unwrap().to_string())) | ||||||
|             } |             } | ||||||
|             "DBMap" => Ok(CacheType::DBMap(Databases::new())), |             "DBMap" => Ok(CacheType::DBMap(Databases::new())), | ||||||
|  |             "TableMap" => Ok(CacheType::TableMap), | ||||||
|             _ => Err(DBError::new("data corruption")), |             _ => Err(DBError::new("data corruption")), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -178,4 +179,21 @@ mod enum_ctype { | |||||||
|         let holder = CacheType::TableMap; |         let holder = CacheType::TableMap; | ||||||
|         assert_eq!(holder.entry_type(), "TableMap"); |         assert_eq!(holder.entry_type(), "TableMap"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     #[test] | ||||||
|  |     fn get_new_database_bytes() { | ||||||
|  |         let holder = CacheType::TableMap; | ||||||
|  |         let mut expected = "TableMap".as_bytes().to_vec(); | ||||||
|  |         expected.push(0); | ||||||
|  |         let output = holder.to_bytes(); | ||||||
|  |         assert_eq!(output, expected); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     #[test] | ||||||
|  |     fn from_new_database_bytes() { | ||||||
|  |         let mut data = "TableMap".as_bytes().to_vec(); | ||||||
|  |         data.push(0); | ||||||
|  |         let output = CacheType::from_bytes(data).unwrap(); | ||||||
|  |         assert_eq!(output.entry_type(), "TableMap"); | ||||||
|  |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user