@@ -309,6 +309,10 @@ pub struct SnakeInfoResponse {
309309 #[ serde( default ) ]
310310 pub color : Option < String > ,
311311 #[ serde( default ) ]
312+ pub head : Option < String > ,
313+ #[ serde( default ) ]
314+ pub tail : Option < String > ,
315+ #[ serde( default ) ]
312316 pub customizations : Option < InfoCustomizations > ,
313317}
314318
@@ -806,4 +810,38 @@ mod tests {
806810 assert_eq ! ( c. head, "" , "default head should be empty" ) ;
807811 assert_eq ! ( c. tail, "" , "default tail should be empty" ) ;
808812 }
813+
814+ #[ test]
815+ fn test_snake_info_response_top_level_head_and_tail ( ) {
816+ let json = r##"{"apiversion":"1","author":"coreyja","color":"#AA66CC","head":"trans-rights-scarf","tail":"bolt","version":null}"## ;
817+ let info: SnakeInfoResponse = serde_json:: from_str ( json) . unwrap ( ) ;
818+ assert_eq ! (
819+ info. color,
820+ Some ( "#AA66CC" . to_string( ) ) ,
821+ "top-level color should be captured"
822+ ) ;
823+ assert_eq ! (
824+ info. head,
825+ Some ( "trans-rights-scarf" . to_string( ) ) ,
826+ "top-level head should be captured"
827+ ) ;
828+ assert_eq ! (
829+ info. tail,
830+ Some ( "bolt" . to_string( ) ) ,
831+ "top-level tail should be captured"
832+ ) ;
833+ assert ! (
834+ info. customizations. is_none( ) ,
835+ "customizations should be None when not present"
836+ ) ;
837+ }
838+
839+ #[ test]
840+ fn test_snake_info_response_top_level_head_null_tail ( ) {
841+ let json =
842+ r##"{"apiversion":"1","color":"#AA66CC","head":"trans-rights-scarf","tail":null}"## ;
843+ let info: SnakeInfoResponse = serde_json:: from_str ( json) . unwrap ( ) ;
844+ assert_eq ! ( info. head, Some ( "trans-rights-scarf" . to_string( ) ) ) ;
845+ assert_eq ! ( info. tail, None , "null tail should deserialize as None" ) ;
846+ }
809847}
0 commit comments