mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 04:52:24 -05:00
reference global logrus (#274)
* reference logrus' global logger instead of passing and storing a logger reference everywhere * always directly use global logrus logger instead of referencing an instance * test suites should also directly use the global logrus logger * rename gin logging function to clarify that it's middleware * correct comments which erroneously referenced removed logger parameter * setting log level for tests now uses logrus' exported type instead of the string value, to guarantee error isn't possible
This commit is contained in:
parent
367bdca250
commit
083099a957
210 changed files with 506 additions and 662 deletions
|
|
@ -86,7 +86,7 @@ func NewTestDB() db.DB {
|
|||
config.DBConfig.Port = int(port)
|
||||
}
|
||||
|
||||
testDB, err := bundb.NewBunDBService(context.Background(), config, NewTestLog())
|
||||
testDB, err := bundb.NewBunDBService(context.Background(), config)
|
||||
if err != nil {
|
||||
logrus.Panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ import (
|
|||
|
||||
// NewTestFederatingDB returns a federating DB with the underlying db
|
||||
func NewTestFederatingDB(db db.DB) federatingdb.DB {
|
||||
return federatingdb.New(db, NewTestConfig(), NewTestLog())
|
||||
return federatingdb.New(db, NewTestConfig())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ import (
|
|||
|
||||
// NewTestFederator returns a federator with the given database and (mock!!) transport controller.
|
||||
func NewTestFederator(db db.DB, tc transport.Controller, storage *kv.KVStore) federation.Federator {
|
||||
return federation.NewFederator(db, NewTestFederatingDB(db), tc, NewTestConfig(), NewTestLog(), NewTestTypeConverter(db), NewTestMediaHandler(db, storage))
|
||||
return federation.NewFederator(db, NewTestFederatingDB(db), tc, NewTestConfig(), NewTestTypeConverter(db), NewTestMediaHandler(db, storage))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,14 @@
|
|||
package testrig
|
||||
|
||||
import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
)
|
||||
|
||||
// NewTestLog returns a trace level logger for testing
|
||||
func NewTestLog() *logrus.Logger {
|
||||
logger, err := log.New("trace")
|
||||
// InitTestLog sets the global logger to trace level for logging
|
||||
func InitTestLog() {
|
||||
err := log.Initialize(logrus.TraceLevel.String())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return logger
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
)
|
||||
|
||||
// NewTestMediaHandler returns a media handler with the default test config, the default test logger,
|
||||
// and the given db and storage.
|
||||
// NewTestMediaHandler returns a media handler with the default test config, and the given db and storage.
|
||||
func NewTestMediaHandler(db db.DB, storage *kv.KVStore) media.Handler {
|
||||
return media.New(NewTestConfig(), db, storage, NewTestLog())
|
||||
return media.New(NewTestConfig(), db, storage)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
)
|
||||
|
||||
// NewTestOauthServer returns an oauth server with the given db, and the default test logger.
|
||||
// NewTestOauthServer returns an oauth server with the given db
|
||||
func NewTestOauthServer(db db.DB) oauth.Server {
|
||||
return oauth.New(context.Background(), db, NewTestLog())
|
||||
return oauth.New(context.Background(), db)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,5 +27,5 @@ import (
|
|||
|
||||
// NewTestProcessor returns a Processor suitable for testing purposes
|
||||
func NewTestProcessor(db db.DB, storage *kv.KVStore, federator federation.Federator) processing.Processor {
|
||||
return processing.NewProcessor(NewTestConfig(), NewTestTypeConverter(db), federator, NewTestOauthServer(db), NewTestMediaHandler(db, storage), storage, NewTestTimelineManager(db), db, NewTestLog())
|
||||
return processing.NewProcessor(NewTestConfig(), NewTestTypeConverter(db), federator, NewTestOauthServer(db), NewTestMediaHandler(db, storage), storage, NewTestTimelineManager(db), db)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
// NewTestRouter returns a Router suitable for testing
|
||||
func NewTestRouter(db db.DB) router.Router {
|
||||
r, err := router.New(context.Background(), NewTestConfig(), db, NewTestLog())
|
||||
r, err := router.New(context.Background(), NewTestConfig(), db)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,5 @@ import (
|
|||
|
||||
// NewTestTimelineManager retuts a new timeline.Manager, suitable for testing, using the given db.
|
||||
func NewTestTimelineManager(db db.DB) timeline.Manager {
|
||||
return timeline.NewManager(db, NewTestTypeConverter(db), NewTestConfig(), NewTestLog())
|
||||
return timeline.NewManager(db, NewTestTypeConverter(db), NewTestConfig())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import (
|
|||
// PER TEST rather than per suite, so that the do function can be set on a test by test (or even more granular)
|
||||
// basis.
|
||||
func NewTestTransportController(client pub.HttpClient, db db.DB) transport.Controller {
|
||||
return transport.NewController(NewTestConfig(), db, &federation.Clock{}, client, NewTestLog())
|
||||
return transport.NewController(NewTestConfig(), db, &federation.Clock{}, client)
|
||||
}
|
||||
|
||||
// NewMockHTTPClient returns a client that conforms to the pub.HttpClient interface,
|
||||
|
|
|
|||
|
|
@ -25,5 +25,5 @@ import (
|
|||
|
||||
// NewTestTypeConverter returned a type converter with the given db and the default test config
|
||||
func NewTestTypeConverter(db db.DB) typeutils.TypeConverter {
|
||||
return typeutils.NewConverter(NewTestConfig(), db, NewTestLog())
|
||||
return typeutils.NewConverter(NewTestConfig(), db)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue