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

Function test_decode_startup_message

tests/protocol_test.rs:56–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54
55#[test]
56fn test_decode_startup_message() {
57 let mut codec = PostgresCodec::new();
58 let mut buf = BytesMut::new();
59
60 // Create a startup message
61 // Length includes: 4 (length) + 4 (version) + "user\0postgres\0\0" (15 bytes)
62 let len = 23i32; // Total message length including length field
63 buf.extend_from_slice(&len.to_be_bytes());
64 buf.extend_from_slice(&196608i32.to_be_bytes()); // Protocol version 3.0
65 buf.extend_from_slice(b"user\0postgres\0\0");
66
67 let msg = codec.decode(&mut buf).unwrap();
68
69 match msg {
70 Some(FrontendMessage::StartupMessage(startup)) => {
71 assert_eq!(startup.protocol_version, 196608);
72 assert_eq!(startup.parameters.get("user"), Some(&"postgres".to_string()));
73 }
74 None => panic!("No message decoded"),
75 Some(other) => panic!("Expected StartupMessage, got {other:?}"),
76 }
77}
78
79#[test]
80fn test_decode_query() {

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected