-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on building tests to validate ChatTransaction
- Loading branch information
1 parent
425bbe9
commit 44da7a5
Showing
5 changed files
with
136 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extern crate sazid; | ||
pub mod app; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::fs::File; | ||
use std::io::Read; | ||
use std::path::PathBuf; | ||
// a test that reads in the file tests/assets/saved_stream_response.json and parses it | ||
// asserting that it is a ChatTransaction::StreamResponse | ||
#[test] | ||
fn test_stream_response_parsing() { | ||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
path.push("tests/assets/saved_stream_response.json"); | ||
let mut file = File::open(path).unwrap(); | ||
let mut contents = String::new(); | ||
let transaction: ChatTransaction; | ||
file.read_to_string(&mut contents).unwrap(); | ||
let parsed = serde_json::from_str::<ChatTransaction>(&contents).unwrap(); | ||
match parsed { | ||
crate::ChatTransaction::StreamResponse { .. } => {}, | ||
_ => panic!("Parsed transaction was not a StreamResponse"), | ||
} | ||
} | ||
} |