Skip to content

Commit 43a52e2

Browse files
committed
Reset zerolog’s log level after each integration test.
1 parent fa1264e commit 43a52e2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

internal/verifier/integration_test_suite.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/10gen/migration-verifier/internal/util"
99
mapset "github.com/deckarep/golang-set/v2"
1010
"github.com/pkg/errors"
11+
"github.com/rs/zerolog"
1112
"github.com/stretchr/testify/suite"
1213
"go.mongodb.org/mongo-driver/bson"
1314
"go.mongodb.org/mongo-driver/mongo"
@@ -27,6 +28,8 @@ type IntegrationTestSuite struct {
2728
testContext context.Context
2829
contextCanceller context.CancelCauseFunc
2930
initialDbNames mapset.Set[string]
31+
32+
zerologGlobalLogLevel zerolog.Level
3033
}
3134

3235
var _ suite.TestingSuite = &IntegrationTestSuite{}
@@ -111,11 +114,14 @@ func (suite *IntegrationTestSuite) SetupTest() {
111114
}
112115

113116
suite.testContext, suite.contextCanceller = ctx, canceller
117+
suite.zerologGlobalLogLevel = zerolog.GlobalLevel()
114118
}
115119

116120
func (suite *IntegrationTestSuite) TearDownTest() {
117121
suite.T().Logf("Tearing down test %#q", suite.T().Name())
118122

123+
zerolog.SetGlobalLevel(suite.zerologGlobalLogLevel)
124+
119125
suite.contextCanceller(errors.Errorf("tearing down test %#q", suite.T().Name()))
120126
suite.testContext, suite.contextCanceller = nil, nil
121127
ctx := context.Background()

internal/verifier/migration_verifier_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ func TestIntegration(t *testing.T) {
5353
metaConnStr: envVals["MVTEST_META"],
5454
}
5555

56+
oldLogLevel := zerolog.GlobalLevel()
57+
zerolog.SetGlobalLevel(zerolog.DebugLevel)
58+
defer zerolog.SetGlobalLevel(oldLogLevel)
59+
5660
suite.Run(t, testSuite)
5761
}
5862

0 commit comments

Comments
 (0)