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

Function TestErrorResponse

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

Source from the content-addressed store, hash-verified

81}
82
83func TestErrorResponse(t *testing.T) {
84 t.Parallel()
85
86 want := &pgproto3.ErrorResponse{
87 Severity: "ERROR",
88 SeverityUnlocalized: "ERROR",
89 Message: `column "foo" does not exist`,
90 File: "parse_relation.c",
91 Code: "42703",
92 Position: 8,
93 Line: 3513,
94 Routine: "errorMissingColumn",
95 }
96
97 raw := []byte{
98 'E', 0, 0, 0, 'f',
99 'S', 'E', 'R', 'R', 'O', 'R', 0,
100 'V', 'E', 'R', 'R', 'O', 'R', 0,
101 'C', '4', '2', '7', '0', '3', 0,
102 'M', 'c', 'o', 'l', 'u', 'm', 'n', 32, '"', 'f', 'o', 'o', '"', 32, 'd', 'o', 'e', 's', 32, 'n', 'o', 't', 32, 'e', 'x', 'i', 's', 't', 0,
103 'P', '8', 0,
104 'F', 'p', 'a', 'r', 's', 'e', '_', 'r', 'e', 'l', 'a', 't', 'i', 'o', 'n', '.', 'c', 0,
105 'L', '3', '5', '1', '3', 0,
106 'R', 'e', 'r', 'r', 'o', 'r', 'M', 'i', 's', 's', 'i', 'n', 'g', 'C', 'o', 'l', 'u', 'm', 'n', 0, 0,
107 }
108
109 server := &interruptReader{}
110 server.push(raw)
111
112 frontend := pgproto3.NewFrontend(server, nil)
113
114 got, err := frontend.Receive()
115 require.NoError(t, err)
116 assert.Equal(t, want, got)
117}
118
119func TestFrontendReceiveExceededMaxBodyLen(t *testing.T) {
120 t.Parallel()

Callers

nothing calls this directly

Calls 3

pushMethod · 0.95
ReceiveMethod · 0.95
NewFrontendFunction · 0.92

Tested by

no test coverage detected