Disable morph logging during TestMain (#30948)

* rm "No TEST_DATABASE... override" log message

Let's only log if this value is actually overridden.

* rm "(Created|Dropped) temporary database" message

* only log "Pinging SQL" on subsequent attempts

* disable morph logging from TestMain

* Fix style issues in store test files

- Add missing parameter to migrate() function calls in tests
- Remove unused log function in settings.go
- Fix formatting with go fmt

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* within sqlstore, use "enable" vs "disable" for clarity

* remove trailing newline from morph logs

---------

Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
Jesse Hallam
2025-05-21 14:31:18 -03:00
коммит произвёл GitHub
родитель 92db356484
Коммит 31a8047973
15 изменённых файлов: 71 добавлений и 55 удалений

Просмотреть файл

@@ -147,6 +147,7 @@ type SqlStore struct {
isBinaryParam bool
pgDefaultTextSearchConfig string
skipMigrations bool
disableMorphLogging bool
quitMonitor chan struct{}
wgMonitor *sync.WaitGroup
@@ -159,6 +160,13 @@ func SkipMigrations() Option {
}
}
func DisableMorphLogging() Option {
return func(s *SqlStore) error {
s.disableMorphLogging = true
return nil
}
}
func New(settings model.SqlSettings, logger mlog.LoggerIFace, metrics einterfaces.MetricsInterface, options ...Option) (*SqlStore, error) {
store := &SqlStore{
rrCounter: 0,
@@ -200,7 +208,7 @@ func New(settings model.SqlSettings, logger mlog.LoggerIFace, metrics einterface
}
if !store.skipMigrations {
err = store.migrate(migrationsDirectionUp, false)
err = store.migrate(migrationsDirectionUp, false, !store.disableMorphLogging)
if err != nil {
return nil, errors.Wrap(err, "failed to apply database migrations")
}
@@ -642,7 +650,6 @@ func (ss *SqlStore) DoesTableExist(tableName string) bool {
`SELECT count(relname) FROM pg_class WHERE relname=$1`,
strings.ToLower(tableName),
)
if err != nil {
mlog.Fatal("Failed to check if table exists", mlog.Err(err))
}
@@ -661,7 +668,6 @@ func (ss *SqlStore) DoesTableExist(tableName string) bool {
`,
tableName,
)
if err != nil {
mlog.Fatal("Failed to check if table exists", mlog.Err(err))
}
@@ -684,7 +690,6 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
strings.ToLower(tableName),
strings.ToLower(columnName),
)
if err != nil {
if err.Error() == "pq: relation \""+strings.ToLower(tableName)+"\" does not exist" {
return false
@@ -708,7 +713,6 @@ func (ss *SqlStore) DoesColumnExist(tableName string, columnName string) bool {
tableName,
columnName,
)
if err != nil {
mlog.Fatal("Failed to check if column exists", mlog.Err(err))
}
@@ -730,7 +734,6 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
WHERE
tgname = $1
`, triggerName)
if err != nil {
mlog.Fatal("Failed to check if trigger exists", mlog.Err(err))
}
@@ -747,7 +750,6 @@ func (ss *SqlStore) DoesTriggerExist(triggerName string) bool {
trigger_schema = DATABASE()
AND trigger_name = ?
`, triggerName)
if err != nil {
mlog.Fatal("Failed to check if trigger exists", mlog.Err(err))
}