Fix TryFrom<Data> impl for Vec<u8>
Fixes #163 Signed-off-by: Jim Crossley <jim@crossleys.org>
This commit is contained in:
parent
65a4782853
commit
70e3b6681b
|
@ -45,12 +45,11 @@ async fn create_event(headers: HeaderMap, body: bytes::Bytes) -> Result<Event, R
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use warp_lib as warp;
|
||||
|
||||
use super::to_event;
|
||||
use warp::test;
|
||||
|
||||
use crate::test::fixtures;
|
||||
use std::convert::TryInto;
|
||||
use warp::test;
|
||||
use warp_lib as warp;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_request() {
|
||||
|
@ -114,6 +113,12 @@ mod tests {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut event = result.clone();
|
||||
let (_datacontenttype, _dataschema, data) = event.take_data();
|
||||
let actual_payload: Vec<u8> = data.unwrap().try_into().unwrap();
|
||||
let expected_payload: Vec<u8> = serde_json::to_vec(&fixtures::json_data()).unwrap();
|
||||
assert_eq!(expected_payload, actual_payload);
|
||||
|
||||
assert_eq!(expected, result);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ impl TryFrom<Data> for Vec<u8> {
|
|||
|
||||
fn try_from(value: Data) -> Result<Self, Self::Error> {
|
||||
match value {
|
||||
Data::Binary(v) => Ok(serde_json::from_slice(&v)?),
|
||||
Data::Binary(v) => Ok(v),
|
||||
Data::Json(v) => Ok(serde_json::to_vec(&v)?),
|
||||
Data::String(s) => Ok(s.into_bytes()),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue