mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-23 11:02:43 +03:00
Remove dead code.
This commit is contained in:
parent
9b4664d9a9
commit
d9fb8e7576
@ -16,52 +16,5 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use crate::cli::CliError;
|
||||
use std::io::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod result;
|
||||
mod value;
|
||||
|
||||
pub fn write_json_report(
|
||||
file_path: PathBuf,
|
||||
results: Vec<serde_json::Value>,
|
||||
) -> Result<(), CliError> {
|
||||
let mut file = match std::fs::File::create(&file_path) {
|
||||
Err(why) => {
|
||||
return Err(CliError {
|
||||
message: format!("Issue writing to {}: {:?}", file_path.display(), why),
|
||||
})
|
||||
}
|
||||
Ok(file) => file,
|
||||
};
|
||||
let serialized = serde_json::to_string_pretty(&results).unwrap();
|
||||
if let Err(why) = file.write_all(serialized.as_bytes()) {
|
||||
Err(CliError {
|
||||
message: format!("Issue writing to {}: {:?}", file_path.display(), why),
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_json(path: PathBuf) -> Result<Vec<serde_json::Value>, CliError> {
|
||||
if path.exists() {
|
||||
let s = match std::fs::read_to_string(path.clone()) {
|
||||
Ok(s) => s,
|
||||
Err(why) => {
|
||||
return Err(CliError {
|
||||
message: format!("Issue reading {} to string to {:?}", path.display(), why),
|
||||
});
|
||||
}
|
||||
};
|
||||
match serde_json::from_str(s.as_str()) {
|
||||
Ok(val) => Ok(val),
|
||||
Err(_) => Err(CliError {
|
||||
message: format!("The file {} is not a valid json file", path.display()),
|
||||
}),
|
||||
}
|
||||
} else {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,11 @@ use crate::http::{
|
||||
use crate::runner::{AssertResult, Call, CaptureResult, EntryResult, HurlResult};
|
||||
|
||||
impl HurlResult {
|
||||
/// Serializes an [`HurlResult`] to a JSON representation.
|
||||
///
|
||||
/// Note: `content` is passed to this method to save asserts and
|
||||
/// errors messages (with lines and columns). This parameter will be removed
|
||||
/// soon and the original content will be accessible through the [`HurlResult`] instance.
|
||||
pub fn to_json(&self, content: &str) -> serde_json::Value {
|
||||
let mut map = serde_json::Map::new();
|
||||
map.insert(
|
||||
|
Loading…
Reference in New Issue
Block a user