MCPcopy
hub / github.com/go-sql-driver/mysql / TestInterpolateParamsJSONRawMessage

Function TestInterpolateParamsJSONRawMessage

connection_test.go:41–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestInterpolateParamsJSONRawMessage(t *testing.T) {
42 mc := &mysqlConn{
43 buf: newBuffer(),
44 maxAllowedPacket: maxPacketSize,
45 cfg: &Config{
46 InterpolateParams: true,
47 },
48 }
49
50 buf, err := json.Marshal(struct {
51 Value int `json:"value"`
52 }{Value: 42})
53 if err != nil {
54 t.Errorf("Expected err=nil, got %#v", err)
55 return
56 }
57 q, err := mc.interpolateParams("SELECT ?", []driver.Value{json.RawMessage(buf)})
58 if err != nil {
59 t.Errorf("Expected err=nil, got %#v", err)
60 return
61 }
62 expected := `SELECT '{\"value\":42}'`
63 if q != expected {
64 t.Errorf("Expected: %q\nGot: %q", expected, q)
65 }
66}
67
68func TestInterpolateParamsTooManyPlaceholders(t *testing.T) {
69 mc := &mysqlConn{

Callers

nothing calls this directly

Calls 2

interpolateParamsMethod · 0.95
newBufferFunction · 0.85

Tested by

no test coverage detected