MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_decode_query

Function test_decode_query

tests/protocol_test.rs:80–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78
79#[test]
80fn test_decode_query() {
81 let mut codec = PostgresCodec::new();
82 let mut buf = BytesMut::new();
83
84 // First decode a startup message to change state
85 let startup_len = 9i32; // 4 (len) + 4 (version) + 1 (null terminator)
86 buf.extend_from_slice(&startup_len.to_be_bytes());
87 buf.extend_from_slice(&196608i32.to_be_bytes());
88 buf.extend_from_slice(b"\0");
89
90 codec.decode(&mut buf).unwrap();
91
92 // Now decode a query
93 buf.clear();
94 buf.put_u8(b'Q'); // Query message
95 buf.extend_from_slice(&13i32.to_be_bytes()); // Length: 4 (len) + 9 ("SELECT 1\0")
96 buf.extend_from_slice(b"SELECT 1\0");
97
98 let msg = codec.decode(&mut buf).unwrap();
99
100 match msg {
101 Some(FrontendMessage::Query(query)) => {
102 assert_eq!(query, "SELECT 1");
103 }
104 None => panic!("No message decoded"),
105 Some(other) => panic!("Expected Query message, got {other:?}"),
106 }
107}
108
109#[test]
110fn test_row_description_encoding() {

Callers

nothing calls this directly

Calls 2

decodeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected