Added empty commit.
This commit is contained in:
		| @@ -196,6 +196,7 @@ mod datatypes { | ||||
|  | ||||
| #[derive(Debug)] | ||||
| enum FromCache { | ||||
|     Ok, | ||||
|     Data(HashMap<String, DataType>), | ||||
|     Error(MTTError), | ||||
| } | ||||
| @@ -205,8 +206,29 @@ struct CacheQuery { | ||||
|     reply: Sender<FromCache>, | ||||
| } | ||||
|  | ||||
| struct CacheCommit { | ||||
|     reply: Sender<FromCache>, | ||||
| } | ||||
|  | ||||
| impl CacheCommit { | ||||
|     fn new(channel: Sender<FromCache>) -> Self { | ||||
|         Self { reply: channel } | ||||
|     } | ||||
| } | ||||
|  | ||||
| mod commits { | ||||
|     use super::*; | ||||
|  | ||||
|     #[test] | ||||
|     fn create() { | ||||
|         let (s, _) = unbounded(); | ||||
|         CacheCommit::new(s); | ||||
|     } | ||||
| } | ||||
|  | ||||
| enum ToCache { | ||||
|     Query(CacheQuery), | ||||
|     Commit(CacheCommit), | ||||
| } | ||||
|  | ||||
| #[derive(Clone)] | ||||
| @@ -265,6 +287,7 @@ impl Cache { | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|                 ToCache::Commit(data) => data.reply.send(FromCache::Ok).await.unwrap(), | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @@ -294,10 +317,7 @@ mod caches { | ||||
|             ids.push(id.to_string()); | ||||
|         } | ||||
|         let (s, r) = unbounded(); | ||||
|         let msg = ToCache::Query( CacheQuery { | ||||
|             ids: ids, | ||||
|             reply: s, | ||||
|         }); | ||||
|         let msg = ToCache::Query(CacheQuery { ids: ids, reply: s }); | ||||
|         channel.send(msg).await.unwrap(); | ||||
|         r.recv().await.unwrap() | ||||
|     } | ||||
| @@ -329,6 +349,20 @@ mod caches { | ||||
|             _ => assert!(false, "{:?} should have been an error.", result), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     #[async_std::test] | ||||
|     async fn empty_commit() { | ||||
|         let dir = tempdir().unwrap(); | ||||
|         let s_cache = start_cache(dir.path()).await; | ||||
|         let (s, r) = unbounded(); | ||||
|         let msg = ToCache::Commit(CacheCommit::new(s)); | ||||
|         s_cache.send(msg).await.unwrap(); | ||||
|         let result = r.recv().await.unwrap(); | ||||
|         match result { | ||||
|             FromCache::Ok => (), | ||||
|             _ => assert!(false, "{:?} should have been an error.", result), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub async fn start_db<P>(_dir: P) -> Result<MoreThanText, MTTError> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user