MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestWriteReadyForQuery

Function TestWriteReadyForQuery

server/protocol_test.go:332–368  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

330}
331
332func TestWriteReadyForQuery(t *testing.T) {
333 tests := []struct {
334 name string
335 txStatus byte
336 }{
337 {"idle", 'I'},
338 {"in transaction", 'T'},
339 {"failed transaction", 'E'},
340 }
341
342 for _, tt := range tests {
343 t.Run(tt.name, func(t *testing.T) {
344 var buf bytes.Buffer
345
346 err := wire.WriteReadyForQuery(&buf, tt.txStatus)
347 if err != nil {
348 t.Fatalf("wire.WriteReadyForQuery() error = %v", err)
349 }
350
351 // Message type should be 'Z'
352 if buf.Bytes()[0] != 'Z' {
353 t.Errorf("message type = %c, want Z", buf.Bytes()[0])
354 }
355
356 // Length should be 5 (4 for length + 1 for status)
357 length := binary.BigEndian.Uint32(buf.Bytes()[1:5])
358 if length != 5 {
359 t.Errorf("length = %d, want 5", length)
360 }
361
362 // Check status
363 if buf.Bytes()[5] != tt.txStatus {
364 t.Errorf("txStatus = %c, want %c", buf.Bytes()[5], tt.txStatus)
365 }
366 })
367 }
368}
369
370func TestWriteErrorResponse(t *testing.T) {
371 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 2

WriteReadyForQueryFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected