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

Function TestErrorsSetLogger

errors_test.go:18–37  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestErrorsSetLogger(t *testing.T) {
19 previous := defaultLogger
20 defer func() {
21 defaultLogger = previous
22 }()
23
24 // set up logger
25 const expected = "prefix: test\n"
26 buffer := bytes.NewBuffer(make([]byte, 0, 64))
27 logger := log.New(buffer, "prefix: ", 0)
28
29 // print
30 SetLogger(logger)
31 defaultLogger.Print("test")
32
33 // check result
34 if actual := buffer.String(); actual != expected {
35 t.Errorf("expected %q, got %q", expected, actual)
36 }
37}
38
39func TestErrorsStrictIgnoreNotes(t *testing.T) {
40 runTests(t, dsn+"&sql_notes=false", func(dbt *DBTest) {

Callers

nothing calls this directly

Calls 3

SetLoggerFunction · 0.85
StringMethod · 0.80
PrintMethod · 0.65

Tested by

no test coverage detected