Sync your own workout data from your "Strong" app
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at master 29 lines 938 B view raw
1use strong_api_lib::models::error::ApiErrorResponse; 2 3#[test] 4fn test_api_error_display() { 5 let err = ApiErrorResponse { 6 code: "AUTH_001".to_string(), 7 description: "Invalid credentials".to_string(), 8 }; 9 assert_eq!(err.to_string(), "AUTH_001: Invalid credentials"); 10} 11 12#[test] 13fn test_api_error_is_std_error() { 14 let err = ApiErrorResponse { 15 code: "ERR".to_string(), 16 description: "something went wrong".to_string(), 17 }; 18 // Verify it satisfies std::error::Error (compile-time + source() returns None) 19 let boxed: Box<dyn std::error::Error> = Box::new(err); 20 assert!(boxed.source().is_none()); 21} 22 23#[test] 24fn test_api_error_deserializes() { 25 let json = r#"{"code":"NOT_FOUND","description":"Resource not found"}"#; 26 let err: ApiErrorResponse = serde_json::from_str(json).unwrap(); 27 assert_eq!(err.code, "NOT_FOUND"); 28 assert_eq!(err.description, "Resource not found"); 29}