| 108 | |
| 109 | #[test] |
| 110 | fn test_row_description_encoding() { |
| 111 | let mut codec = PostgresCodec::new(); |
| 112 | let mut buf = BytesMut::new(); |
| 113 | |
| 114 | let fields = vec![ |
| 115 | FieldDescription { |
| 116 | name: "id".to_string(), |
| 117 | table_oid: 0, |
| 118 | column_id: 1, |
| 119 | type_oid: 23, // int4 |
| 120 | type_size: 4, |
| 121 | type_modifier: -1, |
| 122 | format: 0, // text |
| 123 | }, |
| 124 | FieldDescription { |
| 125 | name: "name".to_string(), |
| 126 | table_oid: 0, |
| 127 | column_id: 2, |
| 128 | type_oid: 25, // text |
| 129 | type_size: -1, |
| 130 | type_modifier: -1, |
| 131 | format: 0, // text |
| 132 | }, |
| 133 | ]; |
| 134 | |
| 135 | let msg = BackendMessage::RowDescription(fields); |
| 136 | codec.encode(msg, &mut buf).unwrap(); |
| 137 | |
| 138 | assert_eq!(buf[0], b'T'); // RowDescription type |
| 139 | // Verify it contains field count and field data |
| 140 | assert!(buf.len() > 30); |
| 141 | } |