-
-
Notifications
You must be signed in to change notification settings - Fork 944
Expand file tree
/
Copy pathhelper_test.go
More file actions
30 lines (25 loc) · 697 Bytes
/
helper_test.go
File metadata and controls
30 lines (25 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package pq
import (
"testing"
"github.com/lib/pq/internal/pqtest"
)
// Called for the side-effect of setting the environment.
func init() { pqtest.DSN("") }
const cancelErrorCode ErrorCode = "57014"
// pqError converts an error to *pq.Error, calling t.Fatal() if the error is nil
// or if this fails.
//
// This should probably be in pqtest, but can't right now due to import cycles,
// and using pq_test package requires some refactoring as it refers to
// unexported symbols.
func pqError(t *testing.T, err error) *Error {
t.Helper()
if err == nil {
t.Fatalf("pqError: error is nil")
}
pqErr, ok := err.(*Error)
if !ok {
t.Fatalf("wrong error %T: %[1]s", err)
}
return pqErr
}