Skip to content

Commit 7b88776

Browse files
authored
chore(testutil): add testutil.GoleakOptions (coder#16070)
- Adds `testutil.GoleakOptions` and consolidates existing options to this location - Pre-emptively adds required ignore for this Dependabot PR to pass CI coder#16066
1 parent 106b1cd commit 7b88776

File tree

36 files changed

+60
-43
lines changed

36 files changed

+60
-43
lines changed

agent/agent_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import (
5858
)
5959

6060
func TestMain(m *testing.M) {
61-
goleak.VerifyTestMain(m)
61+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
6262
}
6363

6464
// NOTE: These tests only work when your default shell is bash for some reason.

agent/agentscripts/agentscripts_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
)
2525

2626
func TestMain(m *testing.M) {
27-
goleak.VerifyTestMain(m)
27+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
2828
}
2929

3030
func TestExecuteBasic(t *testing.T) {

agent/agentssh/agentssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
func TestMain(m *testing.M) {
32-
goleak.VerifyTestMain(m)
32+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
3333
}
3434

3535
func TestNewServer_ServeClient(t *testing.T) {

cli/clitest/clitest_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
"github.com/coder/coder/v2/cli/clitest"
99
"github.com/coder/coder/v2/coderd/coderdtest"
1010
"github.com/coder/coder/v2/pty/ptytest"
11+
"github.com/coder/coder/v2/testutil"
1112
)
1213

1314
func TestMain(m *testing.M) {
14-
goleak.VerifyTestMain(m)
15+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
1516
}
1617

1718
func TestCli(t *testing.T) {

cli/root_internal_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/coder/coder/v2/cli/cliui"
2020
"github.com/coder/coder/v2/cli/telemetry"
2121
"github.com/coder/coder/v2/codersdk"
22+
"github.com/coder/coder/v2/testutil"
2223
"github.com/coder/pretty"
2324
"github.com/coder/serpent"
2425
)
@@ -29,15 +30,7 @@ func TestMain(m *testing.M) {
2930
// See: https://github.com/coder/coder/issues/8954
3031
os.Exit(m.Run())
3132
}
32-
goleak.VerifyTestMain(m,
33-
// The lumberjack library is used by by agent and seems to leave
34-
// goroutines after Close(), fails TestGitSSH tests.
35-
// https://github.com/natefinch/lumberjack/pull/100
36-
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
37-
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).mill.func1"),
38-
// The pq library appears to leave around a goroutine after Close().
39-
goleak.IgnoreTopFunction("github.com/lib/pq.NewDialListener"),
40-
)
33+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
4134
}
4235

4336
func Test_formatExamples(t *testing.T) {

coderd/autobuild/lifecycle_executor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,5 +1256,5 @@ func mustWorkspaceParameters(t *testing.T, client *codersdk.Client, workspaceID
12561256
}
12571257

12581258
func TestMain(m *testing.M) {
1259-
goleak.VerifyTestMain(m)
1259+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
12601260
}

coderd/autobuild/notify/notifier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@ func durations(ds ...time.Duration) []time.Duration {
122122
}
123123

124124
func TestMain(m *testing.M) {
125-
goleak.VerifyTestMain(m)
125+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
126126
}

coderd/coderd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
var updateGoldenFiles = flag.Bool("update", false, "Update golden files")
4040

4141
func TestMain(m *testing.M) {
42-
goleak.VerifyTestMain(m)
42+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
4343
}
4444

4545
func TestBuildInfo(t *testing.T) {

coderd/coderdtest/coderdtest_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ import (
66
"go.uber.org/goleak"
77

88
"github.com/coder/coder/v2/coderd/coderdtest"
9+
"github.com/coder/coder/v2/testutil"
910
)
1011

1112
func TestMain(m *testing.M) {
12-
goleak.VerifyTestMain(m)
13+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
1314
}
1415

1516
func TestNew(t *testing.T) {

coderd/cryptokeys/cache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
func TestMain(m *testing.M) {
21-
goleak.VerifyTestMain(m)
21+
goleak.VerifyTestMain(m, testutil.GoleakOptions...)
2222
}
2323

2424
func TestCryptoKeyCache(t *testing.T) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy