Skip to content

Commit 13182cd

Browse files
committed
.
1 parent 3aa4614 commit 13182cd

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

gel-protocol/tests/client_messages.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,31 @@ fn client_handshake() -> Result<(), Box<dyn Error>> {
5454
Ok(())
5555
}
5656

57+
#[test]
58+
fn parse2() -> Result<(), Box<dyn Error>> {
59+
encoding_eq_ver!(
60+
2,
61+
0,
62+
ClientMessage::Parse(Parse {
63+
annotations: None,
64+
allowed_capabilities: Capabilities::MODIFICATIONS,
65+
compilation_flags: CompilationFlags::INJECT_OUTPUT_TYPE_NAMES,
66+
implicit_limit: Some(77),
67+
input_language: InputLanguage::EdgeQL,
68+
output_format: IoFormat::Binary,
69+
expected_cardinality: Cardinality::AtMostOne,
70+
command_text: String::from("SELECT 1;"),
71+
state: State {
72+
typedesc_id: Uuid::from_u128(0),
73+
data: Bytes::from(""),
74+
},
75+
}),
76+
b"P\0\0\0A\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\x02\0\0\0\0\0\0\0Mbo\
77+
\0\0\0\tSELECT 1;\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
78+
);
79+
Ok(())
80+
}
81+
5782
#[test]
5883
fn parse3() -> Result<(), Box<dyn Error>> {
5984
encoding_eq_ver!(
@@ -79,6 +104,36 @@ fn parse3() -> Result<(), Box<dyn Error>> {
79104
Ok(())
80105
}
81106

107+
#[test]
108+
fn execute2() -> Result<(), Box<dyn Error>> {
109+
encoding_eq_ver!(
110+
2,
111+
0,
112+
ClientMessage::Execute1(Execute1 {
113+
annotations: None,
114+
allowed_capabilities: Capabilities::MODIFICATIONS,
115+
compilation_flags: CompilationFlags::INJECT_OUTPUT_TYPE_NAMES,
116+
implicit_limit: Some(77),
117+
input_language: InputLanguage::EdgeQL,
118+
output_format: IoFormat::Binary,
119+
expected_cardinality: Cardinality::AtMostOne,
120+
command_text: String::from("SELECT 1;"),
121+
state: State {
122+
typedesc_id: Uuid::from_u128(0),
123+
data: Bytes::from(""),
124+
},
125+
input_typedesc_id: Uuid::from_u128(123),
126+
output_typedesc_id: Uuid::from_u128(456),
127+
arguments: Bytes::new(),
128+
}),
129+
b"O\0\0\0e\0\0\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\x02\0\0\0\0\0\0\0Mbo\
130+
\0\0\0\tSELECT 1;\
131+
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
132+
\0\0\0{\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\xc8\0\0\0\0"
133+
);
134+
Ok(())
135+
}
136+
82137
#[test]
83138
fn execute3() -> Result<(), Box<dyn Error>> {
84139
encoding_eq_ver!(

gel-protocol/tests/server_messages.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,77 @@ fn parameter_status() -> Result<(), Box<dyn Error>> {
126126
Ok(())
127127
}
128128

129+
#[test]
130+
fn command_complete1() -> Result<(), Box<dyn Error>> {
131+
encoding_eq!(
132+
ServerMessage::CommandComplete1(CommandComplete1 {
133+
annotations: HashMap::new(),
134+
capabilities: Capabilities::MODIFICATIONS,
135+
status: "okay".to_string(),
136+
state: None,
137+
}),
138+
b"C\0\0\0*\0\0\0\0\0\0\0\0\0\x01\0\0\0\x04okay\
139+
\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
140+
\0\0\0\0"
141+
);
142+
Ok(())
143+
}
144+
145+
#[test]
146+
fn command_data_description2() -> Result<(), Box<dyn Error>> {
147+
encoding_eq_ver!(
148+
2,
149+
0,
150+
ServerMessage::CommandDataDescription1(CommandDataDescription1 {
151+
annotations: HashMap::new(),
152+
capabilities: Capabilities::MODIFICATIONS,
153+
result_cardinality: Cardinality::AtMostOne,
154+
input: RawTypedesc {
155+
proto: ProtocolVersion::new(2, 0),
156+
id: Uuid::from_u128(0xFF),
157+
data: Bytes::from_static(b"\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\0\0"),
158+
},
159+
output: RawTypedesc {
160+
proto: ProtocolVersion::new(2, 0),
161+
id: Uuid::from_u128(0x105),
162+
data: Bytes::from_static(b"\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x05"),
163+
},
164+
}),
165+
bconcat!(b"T\0\0\0[\0\0\0\0\0\0\0\0\0\x01o"
166+
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff"
167+
b"\0\0\0\x13"
168+
b"\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\0"
169+
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x05"
170+
b"\0\0\0\x11"
171+
b"\x02\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x01\x05")
172+
);
173+
encoding_eq_ver!(
174+
2,
175+
0,
176+
ServerMessage::CommandDataDescription1(CommandDataDescription1 {
177+
annotations: HashMap::new(),
178+
capabilities: Capabilities::MODIFICATIONS,
179+
result_cardinality: Cardinality::NoResult,
180+
input: RawTypedesc {
181+
proto: ProtocolVersion::new(2, 0),
182+
id: Uuid::from_u128(0xFF),
183+
data: Bytes::from_static(b"\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\0\0"),
184+
},
185+
output: RawTypedesc {
186+
proto: ProtocolVersion::new(2, 0),
187+
id: Uuid::from_u128(0),
188+
data: Bytes::from_static(b""),
189+
},
190+
}),
191+
bconcat!(b"T\0\0\0J\0\0\0\0\0\0\0\0\0\x01n"
192+
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff"
193+
b"\0\0\0\x13"
194+
b"\x04\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xff\0"
195+
b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
196+
);
197+
Ok(())
198+
}
199+
129200
#[test]
130201
fn data() -> Result<(), Box<dyn Error>> {
131202
encoding_eq!(

0 commit comments

Comments
 (0)