| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 39 | func TestErrorsStrictIgnoreNotes(t *testing.T) { |
| 40 | runTests(t, dsn+"&sql_notes=false", func(dbt *DBTest) { |