MCPcopy
hub / github.com/jackc/pgx / TestFrontendReceiveInterrupted

Function TestFrontendReceiveInterrupted

pgproto3/frontend_test.go:35–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestFrontendReceiveInterrupted(t *testing.T) {
36 t.Parallel()
37
38 server := &interruptReader{}
39 server.push([]byte{'Z', 0, 0, 0, 5})
40
41 frontend := pgproto3.NewFrontend(server, nil)
42
43 msg, err := frontend.Receive()
44 if err == nil {
45 t.Fatal("expected err")
46 }
47 if msg != nil {
48 t.Fatalf("did not expect msg, but %v", msg)
49 }
50
51 server.push([]byte{'I'})
52
53 msg, err = frontend.Receive()
54 if err != nil {
55 t.Fatal(err)
56 }
57 if msg, ok := msg.(*pgproto3.ReadyForQuery); !ok || msg.TxStatus != 'I' {
58 t.Fatalf("unexpected msg: %v", msg)
59 }
60}
61
62func TestFrontendReceiveUnexpectedEOF(t *testing.T) {
63 t.Parallel()

Callers

nothing calls this directly

Calls 3

pushMethod · 0.95
ReceiveMethod · 0.95
NewFrontendFunction · 0.92

Tested by

no test coverage detected