diff --git a/tlmcmddb-csv/src/tlm.rs b/tlmcmddb-csv/src/tlm.rs index 08c02eb..5448c29 100644 --- a/tlmcmddb-csv/src/tlm.rs +++ b/tlmcmddb-csv/src/tlm.rs @@ -13,3 +13,56 @@ pub fn parse_csv(telemetry_name: String, rdr: R) -> Result Result { + let csv = { + let header = include_bytes!("../fixtures/TLM_DB/valid_metadata.csv"); + let body = include_bytes!("../fixtures/TLM_DB/valid_body.csv"); + + let mut csv = header.to_vec(); + csv.extend_from_slice(body); + Cursor::new(csv) + }; + + parse_csv("".to_string(), csv) + } + + #[test] + fn test_read_csv() { + let expected: tlmcmddb::tlm::Telemetry = { + let json = include_bytes!("../fixtures/TLM_DB/valid.json"); + serde_json::from_slice(json).unwrap() + }; + + let actual = parse_testdata().unwrap(); + + assert_eq!(expected, actual) + + // make snapshot + // serde_json::to_writer_pretty( + // std::fs::OpenOptions::new() + // .create(true) + // .write(true) + // .truncate(true) + // .open("fixtures/TLM_DB/valid.json") + // .unwrap(), + // &actual, + // ); + } + + #[test] + fn test_ser_json() { + let expected = include_str!("../fixtures/TLM_DB/valid.json"); + + let tlm = parse_testdata().unwrap(); + let actual = serde_json::to_string_pretty(&tlm).unwrap(); + + assert_eq!(expected, actual) + } +}