diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-08-16 13:06:16 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-08-16 13:19:31 +0300 |
commit | e649e027b724c6d685770735ae6083932943c656 (patch) | |
tree | 1f82ddd7d39cca7fa363f930afffa1ee488dfb40 /internal/testhelper | |
parent | e58e61e98a530e1ccdffbe7e48a8c701a43db3e9 (diff) |
tests: Stop using global logrus logger
Stop using the global logrus logger. In one case we can simply use the
logger provided by `log.Configure()`, while in the other case we can
instead use the logging facilities provided by `testing.TB`.
Diffstat (limited to 'internal/testhelper')
-rw-r--r-- | internal/testhelper/configure.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 7f165ca05..399e20bfc 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -8,9 +8,9 @@ import ( "runtime" "testing" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v16/internal/helper/perm" - gitalylog "gitlab.com/gitlab-org/gitaly/v16/internal/log" + "gitlab.com/gitlab-org/gitaly/v16/internal/log" ) var testDirectory string @@ -81,7 +81,7 @@ func Run(m *testing.M, opts ...RunOption) { // configure sets up the global test configuration. On failure, // terminates the program. func configure() (_ func(), returnedErr error) { - gitalylog.Configure(os.Stdout, "json", "panic") + logger := log.Configure(os.Stdout, "json", "panic") for key, value := range map[string]string{ // We inject the following two variables, which instruct Git to search its @@ -129,7 +129,7 @@ func configure() (_ func(), returnedErr error) { } } - cleanup, err := configureTestDirectory() + cleanup, err := configureTestDirectory(logger) if err != nil { return nil, fmt.Errorf("configuring test directory: %w", err) } @@ -142,7 +142,7 @@ func configure() (_ func(), returnedErr error) { return cleanup, nil } -func configureTestDirectory() (_ func(), returnedErr error) { +func configureTestDirectory(logger logrus.FieldLogger) (_ func(), returnedErr error) { if testDirectory != "" { return nil, errors.New("test directory has already been configured") } @@ -165,7 +165,7 @@ func configureTestDirectory() (_ func(), returnedErr error) { cleanup := func() { if err := os.RemoveAll(testDirectory); err != nil { - log.Errorf("cleaning up test directory: %v", err) + logger.Errorf("cleaning up test directory: %v", err) } } defer func() { |