diff --git a/conn/node_test.go b/conn/node_test.go index a9729e529f0..38aae3a2c26 100644 --- a/conn/node_test.go +++ b/conn/node_test.go @@ -20,7 +20,6 @@ import ( "bytes" "context" "fmt" - "os" "sync" "testing" "time" @@ -62,10 +61,7 @@ func (n *Node) run(wg *sync.WaitGroup) { } func TestProposal(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() store := raftwal.Init(dir) rc := &pb.RaftContext{Id: 1} diff --git a/dgraph/cmd/live/load-json/load_test.go b/dgraph/cmd/live/load-json/load_test.go index fdb80c3e3f6..4749a7c22a5 100644 --- a/dgraph/cmd/live/load-json/load_test.go +++ b/dgraph/cmd/live/load-json/load_test.go @@ -188,9 +188,9 @@ func TestMain(m *testing.M) { // Try to create any files in a dedicated temp directory that gets cleaned up // instead of all over /tmp or the working directory. tmpDir, err := os.MkdirTemp("", "test.tmp-") - x.Check(err) - x.Check(os.Chdir(tmpDir)) + x.Panic(err) + x.Panic(os.Chdir(tmpDir)) defer os.RemoveAll(tmpDir) - _ = m.Run() + m.Run() } diff --git a/dgraph/cmd/live/load-uids/load_test.go b/dgraph/cmd/live/load-uids/load_test.go index f1627f85ada..130ebaa6955 100644 --- a/dgraph/cmd/live/load-uids/load_test.go +++ b/dgraph/cmd/live/load-uids/load_test.go @@ -394,15 +394,15 @@ func TestMain(m *testing.M) { if err != nil { log.Fatalf("Error while getting a dgraph client: %v", err) } - x.Check(dg.Alter( + x.Panic(dg.Alter( context.Background(), &api.Operation{DropAll: true})) // Try to create any files in a dedicated temp directory that gets cleaned up // instead of all over /tmp or the working directory. tmpDir, err := os.MkdirTemp("", "test.tmp-") - x.Check(err) - x.Check(os.Chdir(tmpDir)) + x.Panic(err) + x.Panic(os.Chdir(tmpDir)) defer os.RemoveAll(tmpDir) - _ = m.Run() + m.Run() } diff --git a/dgraph/cmd/version/version_test.go b/dgraph/cmd/version/version_test.go index 5411091e814..a1824c576e5 100644 --- a/dgraph/cmd/version/version_test.go +++ b/dgraph/cmd/version/version_test.go @@ -12,15 +12,10 @@ import ( // Test `dgraph version` with an empty config file. func TestDgraphVersion(t *testing.T) { - tmpPath, err := os.MkdirTemp("", "test.tmp-") - require.NoError(t, err) - defer os.RemoveAll(tmpPath) - + tmpPath := t.TempDir() configPath := filepath.Join(tmpPath, "config.yml") configFile, err := os.Create(configPath) require.NoError(t, err) defer configFile.Close() - - err = testutil.Exec(testutil.DgraphBinaryPath(), "version", "--config", configPath) - require.NoError(t, err) + require.NoError(t, testutil.Exec(testutil.DgraphBinaryPath(), "version", "--config", configPath)) } diff --git a/dql/parser_test.go b/dql/parser_test.go index 179d7d76f26..7a0c110848c 100644 --- a/dql/parser_test.go +++ b/dql/parser_test.go @@ -4019,7 +4019,7 @@ func TestParseRegexp6(t *testing.T) { } func TestMain(m *testing.M) { - _ = m.Run() + m.Run() } func TestCountAtRoot(t *testing.T) { diff --git a/edgraph/server_test.go b/edgraph/server_test.go index 0fcc94ad6e9..f898537c672 100644 --- a/edgraph/server_test.go +++ b/edgraph/server_test.go @@ -18,7 +18,6 @@ package edgraph import ( "context" - "os" "testing" "github.com/stretchr/testify/require" @@ -135,9 +134,7 @@ func TestValidateKeys(t *testing.T) { func TestParseSchemaFromAlterOperation(t *testing.T) { md := metadata.New(map[string]string{"namespace": "123"}) ctx := metadata.NewIncomingContext(context.Background(), md) - dir, err := os.MkdirTemp("", "storetest_") - defer os.RemoveAll(dir) - x.Check(err) + dir := t.TempDir() ps, err := badger.OpenManaged(badger.DefaultOptions(dir)) x.Check(err) defer ps.Close() diff --git a/ee/acl/acl_test.go b/ee/acl/acl_test.go index 75705134c93..c57ab7cfd35 100644 --- a/ee/acl/acl_test.go +++ b/ee/acl/acl_test.go @@ -3623,5 +3623,5 @@ func TestDropAllShouldResetGuardiansAndGroot(t *testing.T) { func TestMain(m *testing.M) { adminEndpoint = "http://" + testutil.SockAddrHttp + "/admin" fmt.Printf("Using adminEndpoint for acl package: %s\n", adminEndpoint) - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go b/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go index 57a90eede7d..46b50b238d5 100644 --- a/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go +++ b/graphql/e2e/auth_closed_by_default/auth_closed_by_default_test.go @@ -203,5 +203,5 @@ func TestMain(m *testing.M) { authSchema, err := testutil.AppendAuthInfo(schema, algo, "../auth/sample_public_key.pem", true) x.Panic(err) common.BootstrapServer(authSchema, data) - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/custom_logic/custom_logic_test.go b/graphql/e2e/custom_logic/custom_logic_test.go index e9d6cda3074..d4da655df86 100644 --- a/graphql/e2e/custom_logic/custom_logic_test.go +++ b/graphql/e2e/custom_logic/custom_logic_test.go @@ -3264,5 +3264,5 @@ func TestMain(m *testing.M) { x.Log(err, "Waited for GraphQL test server to become available, but it never did.") os.Exit(1) } - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/directives/dgraph_directives_test.go b/graphql/e2e/directives/dgraph_directives_test.go index ae6b76b6edd..cc8571b2468 100644 --- a/graphql/e2e/directives/dgraph_directives_test.go +++ b/graphql/e2e/directives/dgraph_directives_test.go @@ -59,5 +59,5 @@ func TestMain(m *testing.M) { common.BootstrapServer(schema, data) - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/normal/normal_test.go b/graphql/e2e/normal/normal_test.go index fdac4a0d64b..293cd94885e 100644 --- a/graphql/e2e/normal/normal_test.go +++ b/graphql/e2e/normal/normal_test.go @@ -57,5 +57,5 @@ func TestMain(m *testing.M) { common.BootstrapServer(schema, data) - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/schema/schema_test.go b/graphql/e2e/schema/schema_test.go index e1765764fcf..e79540ee529 100644 --- a/graphql/e2e/schema/schema_test.go +++ b/graphql/e2e/schema/schema_test.go @@ -712,5 +712,5 @@ func updateGQLSchemaConcurrent(t *testing.T, schema, authority string) bool { func TestMain(m *testing.M) { x.Panic(common.CheckGraphQLStarted(common.GraphqlAdminURL)) - _ = m.Run() + m.Run() } diff --git a/graphql/e2e/subscription/subscription_test.go b/graphql/e2e/subscription/subscription_test.go index f5a0b78712b..a961a235c71 100644 --- a/graphql/e2e/subscription/subscription_test.go +++ b/graphql/e2e/subscription/subscription_test.go @@ -1061,5 +1061,5 @@ func TestSubscriptionWithCustomDQL(t *testing.T) { func TestMain(m *testing.M) { x.Panic(common.CheckGraphQLStarted(common.GraphqlAdminURL)) - _ = m.Run() + m.Run() } diff --git a/graphql/schema/schemagen_test.go b/graphql/schema/schemagen_test.go index 35ed237d4fa..6c852eb400b 100644 --- a/graphql/schema/schemagen_test.go +++ b/graphql/schema/schemagen_test.go @@ -350,5 +350,5 @@ func TestMain(m *testing.M) { x.Config.GraphQL = z.NewSuperFlag("lambda-url=http://localhost:8086/graphql-worker;"). MergeAndCheckDefault("lambda-url=;") // now run the tests - _ = m.Run() + m.Run() } diff --git a/posting/list_test.go b/posting/list_test.go index b3cc8961a17..b00f69d8e52 100644 --- a/posting/list_test.go +++ b/posting/list_test.go @@ -1457,18 +1457,16 @@ func TestMain(m *testing.M) { Config.CommitFraction = 0.10 dir, err := os.MkdirTemp("", "storetest_") - x.Check(err) + x.Panic(err) + defer os.RemoveAll(dir) ps, err = badger.OpenManaged(badger.DefaultOptions(dir)) - x.Check(err) + x.Panic(err) // Not using posting list cache Init(ps, 0) schema.Init(ps) - r := m.Run() - - os.RemoveAll(dir) - os.Exit(r) + m.Run() } func BenchmarkAddMutations(b *testing.B) { diff --git a/posting/writer_test.go b/posting/writer_test.go index b8b3404dd53..71b10b7270f 100644 --- a/posting/writer_test.go +++ b/posting/writer_test.go @@ -19,7 +19,6 @@ package posting import ( "fmt" "math" - "os" "sync" "testing" @@ -89,9 +88,7 @@ func BenchmarkWriter(b *testing.B) { // Vanilla TxnWriter b.Run("TxnWriter", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir @@ -114,9 +111,7 @@ func BenchmarkWriter(b *testing.B) { }) // Single threaded BatchWriter b.Run("WriteBatch1", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir @@ -137,9 +132,7 @@ func BenchmarkWriter(b *testing.B) { }) // Multi threaded Batchwriter with thread contention in WriteBatch b.Run("WriteBatchMultThreadDiffWB", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir @@ -165,9 +158,7 @@ func BenchmarkWriter(b *testing.B) { }) // Multi threaded Batchwriter with thread contention in SetEntry b.Run("WriteBatchMultThreadSameWB", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir @@ -193,9 +184,7 @@ func BenchmarkWriter(b *testing.B) { } }) b.Run("WriteBatchSingleThreadDiffWB", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir @@ -215,9 +204,7 @@ func BenchmarkWriter(b *testing.B) { } }) b.Run("WriteBatchSingleThreadSameWB", func(b *testing.B) { - tmpIndexDir, err := os.MkdirTemp("", "dgraph") - require.NoError(b, err) - defer os.RemoveAll(tmpIndexDir) + tmpIndexDir := b.TempDir() dbOpts.Dir = tmpIndexDir dbOpts.ValueDir = tmpIndexDir diff --git a/query/cloud_test.go b/query/cloud_test.go index 2389f1234cf..32c5281f6cb 100644 --- a/query/cloud_test.go +++ b/query/cloud_test.go @@ -27,13 +27,11 @@ import ( func TestMain(m *testing.M) { c, err := dgraphtest.NewDCloudCluster() - if err != nil { - panic(err) - } + x.Panic(err) defer c.Cleanup() client = c.Client() dc = c populateCluster() - os.Exit(m.Run()) + m.Run() } diff --git a/query/integration_test.go b/query/integration_test.go index f0088816595..2cae4f62387 100644 --- a/query/integration_test.go +++ b/query/integration_test.go @@ -19,7 +19,6 @@ package query import ( - "os" "testing" "github.com/dgraph-io/dgraph/dgraphtest" @@ -32,8 +31,8 @@ func TestMain(m *testing.M) { var err error client, err = testutil.DgraphClientWithGroot(testutil.SockAddr) - x.CheckfNoTrace(err) + x.Panic(err) populateCluster() - os.Exit(m.Run()) + m.Run() } diff --git a/raftwal/encryption_test.go b/raftwal/encryption_test.go index b162671d8a2..f07b1f95434 100644 --- a/raftwal/encryption_test.go +++ b/raftwal/encryption_test.go @@ -20,7 +20,6 @@ import ( "log" "math" "math/rand" - "os" "testing" "github.com/stretchr/testify/require" @@ -29,9 +28,7 @@ import ( func TestEntryReadWrite(t *testing.T) { key := []byte("badger16byteskey") - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) - defer os.RemoveAll(dir) + dir := t.TempDir() ds, err := InitEncrypted(dir, key) require.NoError(t, err) @@ -67,11 +64,9 @@ func TestEntryReadWrite(t *testing.T) { // TestLogRotate writes enough log file entries to cause 1 file rotation. func TestLogRotate(t *testing.T) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() el, err := openWal(dir) require.NoError(t, err) - defer os.RemoveAll(dir) // Generate deterministic entries using a seed. const SEED = 1 @@ -123,17 +118,14 @@ func TestLogRotate(t *testing.T) { // TestLogGrow writes data of sufficient size to grow the log file. func TestLogGrow(t *testing.T) { test := func(t *testing.T, key []byte) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() ds, err := InitEncrypted(dir, key) require.NoError(t, err) - defer os.RemoveAll(dir) - - var entries []raftpb.Entry const numEntries = (maxNumEntries * 3) / 2 // 5KB * 30000 is ~ 150MB, this will cause the log file to grow. + var entries []raftpb.Entry for i := 0; i < numEntries; i++ { data := make([]byte, 5<<10) rand.Read(data) diff --git a/raftwal/storage_test.go b/raftwal/storage_test.go index a1f1e98e63f..45917a603d1 100644 --- a/raftwal/storage_test.go +++ b/raftwal/storage_test.go @@ -48,10 +48,7 @@ import ( ) func TestStorageTerm(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}} @@ -96,10 +93,7 @@ func TestStorageTerm(t *testing.T) { } func TestStorageEntries(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}} @@ -144,10 +138,7 @@ func TestStorageEntries(t *testing.T) { } func TestStorageLastIndex(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}} @@ -172,10 +163,7 @@ func TestStorageLastIndex(t *testing.T) { } func TestStorageFirstIndex(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}} @@ -187,11 +175,9 @@ func TestStorageFirstIndex(t *testing.T) { } func TestStorageCreateSnapshot(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) + ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}} cs := &raftpb.ConfState{Nodes: []uint64{1, 2, 3}} data := []byte("data") @@ -222,10 +208,7 @@ func TestStorageCreateSnapshot(t *testing.T) { } func TestStorageAppend(t *testing.T) { - dir, err := os.MkdirTemp("", "badger") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := Init(dir) ents := []raftpb.Entry{{Index: 3, Term: 3}, {Index: 4, Term: 4}, {Index: 5, Term: 5}} @@ -284,8 +267,7 @@ func TestStorageAppend(t *testing.T) { } func TestMetaFile(t *testing.T) { - dir, err := os.MkdirTemp("", "badger-test") - require.NoError(t, err) + dir := t.TempDir() mf, err := newMetaFile(dir) require.NoError(t, err) @@ -331,8 +313,7 @@ func TestMetaFile(t *testing.T) { } func TestEntryFile(t *testing.T) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() el, err := openWal(dir) require.NoError(t, err) require.Equal(t, uint64(1), el.firstIndex()) @@ -351,8 +332,7 @@ func TestEntryFile(t *testing.T) { } func TestTruncateStorage(t *testing.T) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() ds, err := InitEncrypted(dir, nil) require.NoError(t, err) defer os.RemoveAll(dir) @@ -431,8 +411,8 @@ func TestTruncateStorage(t *testing.T) { func TestStorageOnlySnap(t *testing.T) { test := func(t *testing.T, key []byte) { x.WorkerConfig.EncryptionKey = key - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() + ds, err := InitEncrypted(dir, key) require.NoError(t, err) t.Logf("Creating dir: %s\n", dir) @@ -466,8 +446,8 @@ func TestStorageOnlySnap(t *testing.T) { func TestStorageBig(t *testing.T) { test := func(t *testing.T, key []byte) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) + dir := t.TempDir() + ds, err := InitEncrypted(dir, key) require.NoError(t, err) defer os.RemoveAll(dir) diff --git a/schema/parse_test.go b/schema/parse_test.go index b5e4c015821..d9a350b9835 100644 --- a/schema/parse_test.go +++ b/schema/parse_test.go @@ -652,15 +652,14 @@ func TestMain(m *testing.M) { x.Init() dir, err := os.MkdirTemp("", "storetest_") - x.Check(err) + x.Panic(err) + defer os.RemoveAll(dir) + kvOpt := badger.DefaultOptions(dir) ps, err = badger.OpenManaged(kvOpt) - x.Check(err) - Init(ps) + x.Panic(err) + defer ps.Close() - r := m.Run() - - ps.Close() - os.RemoveAll(dir) - os.Exit(r) + Init(ps) + m.Run() } diff --git a/systest/loader/loader_test.go b/systest/loader/loader_test.go index 7007fd954b5..a6de780c09a 100644 --- a/systest/loader/loader_test.go +++ b/systest/loader/loader_test.go @@ -21,7 +21,6 @@ package main import ( "context" "fmt" - "os" "path/filepath" "testing" @@ -48,9 +47,7 @@ func TestLoaderXidmap(t *testing.T) { require.NoError(t, err) ctx := context.Background() testutil.DropAll(t, dg) - tmpDir, err := os.MkdirTemp("", "loader_test") - require.NoError(t, err) - defer os.RemoveAll(tmpDir) + tmpDir := t.TempDir() data, err := filepath.Abs("testdata/first.rdf.gz") require.NoError(t, err) diff --git a/systest/multi-tenancy/basic_test.go b/systest/multi-tenancy/basic_test.go index f892a76f05f..1091dfe2081 100644 --- a/systest/multi-tenancy/basic_test.go +++ b/systest/multi-tenancy/basic_test.go @@ -307,12 +307,7 @@ type liveOpts struct { } func liveLoadData(t *testing.T, opts *liveOpts) error { - // Prepare directories. - dir, err := os.MkdirTemp("", "multi") - require.NoError(t, err) - defer func() { - os.RemoveAll(dir) - }() + dir := t.TempDir() rdfFile := filepath.Join(dir, "rdfs.rdf") require.NoError(t, os.WriteFile(rdfFile, []byte(opts.rdfs), 0644)) schemaFile := filepath.Join(dir, "schema.txt") @@ -596,5 +591,5 @@ func TestNameSpaceLimitFlag(t *testing.T) { func TestMain(m *testing.M) { fmt.Printf("Using adminEndpoint : %s for multi-tenancy test.\n", testutil.AdminUrl()) - _ = m.Run() + m.Run() } diff --git a/worker/draft_test.go b/worker/draft_test.go index e298b0ed01e..7ef617e71d8 100644 --- a/worker/draft_test.go +++ b/worker/draft_test.go @@ -17,7 +17,6 @@ package worker import ( - "os" "testing" "github.com/stretchr/testify/require" @@ -50,10 +49,7 @@ func getEntryForCommit(index, startTs, commitTs uint64) raftpb.Entry { } func TestCalculateSnapshot(t *testing.T) { - dir, err := os.MkdirTemp("", "raftwal") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() ds := raftwal.Init(dir) defer ds.Close() diff --git a/worker/export_test.go b/worker/export_test.go index 8bc00be0673..d4f69a137a8 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -245,10 +245,7 @@ func TestExportRdf(t *testing.T) { [0x2] name: string @index(exact) . `) - bdir, err := os.MkdirTemp("", "export") - require.NoError(t, err) - defer os.RemoveAll(bdir) - + bdir := t.TempDir() time.Sleep(1 * time.Second) // We have 4 friend type edges. FP("friends")%10 = 2. @@ -347,10 +344,7 @@ func TestExportJson(t *testing.T) { initTestExport(t, `name: string @index(exact) . [0x2] name: string @index(exact) .`) - bdir, err := os.MkdirTemp("", "export") - require.NoError(t, err) - defer os.RemoveAll(bdir) - + bdir := t.TempDir() time.Sleep(1 * time.Second) // We have 4 friend type edges. FP("friends")%10 = 2. @@ -411,13 +405,8 @@ const exportRequest = `mutation export($format: String!) { }` func TestExportFormat(t *testing.T) { - tmpdir, err := os.MkdirTemp("", "export") - require.NoError(t, err) - defer os.RemoveAll(tmpdir) - adminUrl := "http://" + testutil.SockAddrHttp + "/admin" - err = testutil.CheckForGraphQLEndpointToReady(t) - require.NoError(t, err) + require.NoError(t, testutil.CheckForGraphQLEndpointToReady(t)) params := testutil.GraphQLParams{ Query: exportRequest, diff --git a/worker/worker_test.go b/worker/worker_test.go index 57449249dbd..16b1e83beed 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -391,5 +391,5 @@ func TestMain(m *testing.M) { posting.Init(ps, 0) Init(ps) - _ = m.Run() + m.Run() } diff --git a/x/error_test.go b/x/error_test.go index e76cd92df8b..910cc018913 100644 --- a/x/error_test.go +++ b/x/error_test.go @@ -28,5 +28,5 @@ func TestMain(m *testing.M) { fmt.Printf("error setting debug mode: %v\n", err) } - _ = m.Run() + m.Run() } diff --git a/xidmap/xidmap_test.go b/xidmap/xidmap_test.go index be5549e79c8..831711c3b77 100644 --- a/xidmap/xidmap_test.go +++ b/xidmap/xidmap_test.go @@ -5,7 +5,6 @@ package xidmap import ( "fmt" "math/rand" - "os" "runtime" "strconv" "sync" @@ -24,10 +23,7 @@ import ( // Opens a badger db and runs a a test on it. func withDB(t *testing.T, test func(db *badger.DB)) { - dir, err := os.MkdirTemp(".", "badger-test") - require.NoError(t, err) - defer os.RemoveAll(dir) - + dir := t.TempDir() opt := badger.LSMOnlyOptions(dir) db, err := badger.Open(opt) require.NoError(t, err)