apolloconfig 0.1.0

apolloconfig
Documentation
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

//
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct ErrJson {
    pub timestamp: DateTime<Utc>,
    pub status: u16,
    pub error: Option<Box<str>>,
    pub path: Option<Box<str>>,
    pub message: Option<Box<str>>,
    pub exception: Option<Box<str>>,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_de() {
        //
        match serde_json::from_str::<ErrJson>(include_str!(
            "../../tests/response_body_json_files/err_wrong_access_key_secret.json"
        )) {
            Ok(err_json) => {
                println!("{:?}", err_json);
            }
            Err(err) => panic!("{}", err),
        }

        //
        match serde_json::from_str::<ErrJson>(include_str!(
            "../../tests/response_body_json_files/err_invalid_format_of_notifications.json"
        )) {
            Ok(err_json) => {
                println!("{:?}", err_json);
            }
            Err(_err) => {
                // TODO, the server bug, invalid RFC 3339 format
                // "timestamp": "2022-06-05T12:26:48.139"
            }
        }
    }
}