| 29 | ) |
| 30 | |
| 31 | func TestGormLogAdapter_Info(t *testing.T) { |
| 32 | var ( |
| 33 | gormLogAdapter = database.GormLogAdapter{ |
| 34 | SlowQueryWarnThreshold: time.Minute, |
| 35 | SlowQueryErrorThreshold: time.Minute, |
| 36 | } |
| 37 | ) |
| 38 | |
| 39 | var buf bytes.Buffer |
| 40 | slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{}))) |
| 41 | |
| 42 | expected := fmt.Sprintf(`msg="message %d %s %f"`, 1, "arg", 2.0) |
| 43 | gormLogAdapter.Info(context.TODO(), "message %d %s %f", 1, "arg", 2.0) |
| 44 | if !strings.Contains(buf.String(), expected) { |
| 45 | t.Errorf("gormLogAdapter output does not contain expected\nOutput:%sExpected:%s", buf.String(), expected) |
| 46 | } |
| 47 | } |