fix: Enable goleak for cli tests (#3370)

This commit is contained in:
Mathias Fredriksson
2022-08-12 21:02:10 +03:00
committed by GitHub
parent 0e8c68ebc5
commit 010f64e8e9
3 changed files with 25 additions and 8 deletions
+8 -4
View File
@@ -1,10 +1,10 @@
package cli
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
)
func Test_formatExamples(t *testing.T) {
@@ -67,7 +67,11 @@ func Test_formatExamples(t *testing.T) {
}
func TestMain(m *testing.M) {
// Replace with goleak.VerifyTestMain(m) when we enable goleak.
os.Exit(m.Run())
// goleak.VerifyTestMain(m)
goleak.VerifyTestMain(m,
// The lumberjack library is used by by agent and seems to leave
// goroutines after Close(), fails TestGitSSH tests.
// https://github.com/natefinch/lumberjack/pull/100
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).millRun"),
goleak.IgnoreTopFunction("gopkg.in/natefinch/lumberjack%2ev2.(*Logger).mill.func1"),
)
}