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

Function testJSONString

values_test.go:122–136  ·  view source on GitHub ↗
(t testing.TB, conn *pgx.Conn, typename string)

Source from the content-addressed store, hash-verified

120}
121
122func testJSONString(t testing.TB, conn *pgx.Conn, typename string) {
123 input := `{"key": "value"}`
124 expectedOutput := map[string]string{"key": "value"}
125 var output map[string]string
126 err := conn.QueryRow(context.Background(), "select $1::"+typename, input).Scan(&output)
127 if err != nil {
128 t.Errorf("%s: QueryRow Scan failed: %v", typename, err)
129 return
130 }
131
132 if !reflect.DeepEqual(expectedOutput, output) {
133 t.Errorf("%s: Did not transcode map[string]string successfully: %v is not %v", typename, expectedOutput, output)
134 return
135 }
136}
137
138func testJSONStringPointer(t testing.TB, conn *pgx.Conn, typename string) {
139 input := `{"key": "value"}`

Callers 1

Calls 2

ScanMethod · 0.65
QueryRowMethod · 0.65

Tested by

no test coverage detected