MCPcopy Create free account
hub / github.com/lib/pq / TestErrorSQLState

Function TestErrorSQLState

error_test.go:19–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestErrorSQLState(t *testing.T) {
20 r := readBuf([]byte{67, 52, 48, 48, 48, 49, 0, 0}) // 40001
21 err := parseError(&r, "")
22 var sqlErr interface{ SQLState() string }
23 if !errors.As(err, &sqlErr) {
24 t.Fatal("SQLState interface not satisfied")
25 }
26 if state := err.SQLState(); state != "40001" {
27 t.Fatalf("unexpected SQL state %v", state)
28 }
29}
30
31func TestErrorClass(t *testing.T) {
32 t.Parallel()

Callers

nothing calls this directly

Calls 4

readBufTypeAlias · 0.85
parseErrorFunction · 0.85
SQLStateMethod · 0.80
FatalMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…