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

Function newBufferedConn

server/query_source_test.go:80–97  ·  view source on GitHub ↗

newBufferedConn builds a clientConn that writes to an in-memory buffer, for asserting the exact backend messages a simple query produces. The returned *bytes.Buffer holds the flushed output after handleQuery.

(exec QueryExecutor)

Source from the content-addressed store, hash-verified

78 }
79 var coded interface{ SQLState() string }
80 if !errors.As(err, &coded) || coded.SQLState() != "22023" {
81 t.Fatalf("applyStartupQuerySource(%.40q) error = %v, want SQLSTATE 22023", raw, err)
82 }
83 if !strings.Contains(err.Error(), `"standard"`) || !strings.Contains(err.Error(), `"endpoints"`) {
84 t.Fatalf("rejection must name the valid values, got %q", err.Error())
85 }
86 if got := c.QuerySource(); got != "standard" {
87 t.Fatalf("after rejected startup option, QuerySource() = %q, want default %q", got, "standard")
88 }
89 }
90}
91
92// wireMsg is a decoded backend protocol message: a type byte and its body.
93type wireMsg struct {
94 typ byte
95 body []byte
96}
97
98// parseWireMsgs decodes the sequence of length-prefixed backend messages a
99// clientConn wrote to its buffer (type byte + 4-byte length incl. length).
100func parseWireMsgs(t *testing.T, buf []byte) []wireMsg {

Calls

no outgoing calls

Tested by

no test coverage detected