63187ee905
Export CurrentDialect(), return setup errors when debug logger is not registered, and guard DestName logging when the module is uninitialized. Co-authored-by: Cursor <cursoragent@cursor.com>
33 lines
662 B
Go
33 lines
662 B
Go
package dbxshared
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
type testDialect string
|
|
|
|
func (d testDialect) String() string { return string(d) }
|
|
|
|
type stubLogger struct{}
|
|
|
|
func (stubLogger) InitLogger() {}
|
|
|
|
func TestInitLogger_UnregisteredDialect(t *testing.T) {
|
|
ResetLoggerRegistry()
|
|
t.Cleanup(ResetLoggerRegistry)
|
|
|
|
err := InitLogger(testDialect("mysql"))
|
|
assert.ErrorContains(t, err, "blank-import dbxm")
|
|
}
|
|
|
|
func TestInitLogger_RegisteredDialect(t *testing.T) {
|
|
ResetLoggerRegistry()
|
|
t.Cleanup(ResetLoggerRegistry)
|
|
|
|
RegisterLogger(testDialect("mysql"), stubLogger{})
|
|
err := InitLogger(testDialect("mysql"))
|
|
assert.NoError(t, err)
|
|
}
|