From 677c35bf7d369559f1f2d9e264e7c91151544ad9 Mon Sep 17 00:00:00 2001 From: Aman Mangal Date: Sat, 11 Mar 2023 16:01:59 +0530 Subject: [PATCH] recreate the context variable for parallel test Also, use require.NoError instead of require.Nil for ensuring that error is nil. This prints better when err is not nil. --- dql/upsert_test.go | 18 +++++++------- edgraph/access_ee_test.go | 6 ++--- ee/acl/acl_test.go | 6 ++--- graphql/e2e/auth/auth_test.go | 10 ++++---- graphql/e2e/common/query.go | 4 ++-- graphql/e2e/subscription/subscription_test.go | 24 +++++++++---------- graphql/resolve/auth_test.go | 10 ++++---- graphql/resolve/mutation_test.go | 4 ++-- graphql/resolve/query_test.go | 2 +- query/fastjson_test.go | 2 +- query/outputnode_test.go | 2 +- schema/parse_test.go | 2 +- systest/acl/restore/acl_restore_test.go | 2 +- systest/audit/audit_test.go | 4 ++-- systest/bgindex/count_test.go | 2 +- systest/bgindex/parallel_test.go | 2 +- systest/bgindex/reverse_test.go | 2 +- systest/bgindex/string_test.go | 2 +- systest/cdc/cdc_test.go | 6 ++--- tok/tok_test.go | 2 +- x/log_writer_test.go | 22 ++++++++--------- 21 files changed, 67 insertions(+), 67 deletions(-) diff --git a/dql/upsert_test.go b/dql/upsert_test.go index e22f5941c8d..a7d6ec1e7b0 100644 --- a/dql/upsert_test.go +++ b/dql/upsert_test.go @@ -181,7 +181,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestUpsertEx1(t *testing.T) { @@ -205,7 +205,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestUpsertWithSpaces(t *testing.T) { @@ -238,7 +238,7 @@ upsert } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestUpsertWithBlankNode(t *testing.T) { @@ -262,7 +262,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestUpsertMutationThenQuery(t *testing.T) { @@ -286,7 +286,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestUpsertWithFilter(t *testing.T) { @@ -311,7 +311,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestConditionalUpsertWithNewlines(t *testing.T) { @@ -338,7 +338,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestConditionalUpsertFuncTree(t *testing.T) { @@ -367,7 +367,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestConditionalUpsertMultipleFuncArg(t *testing.T) { @@ -396,7 +396,7 @@ upsert { } ` _, err := ParseMutation(query) - require.Nil(t, err) + require.NoError(t, err) } func TestConditionalUpsertErrMissingRightRound(t *testing.T) { diff --git a/edgraph/access_ee_test.go b/edgraph/access_ee_test.go index 663441b4ae6..78642c15eb6 100644 --- a/edgraph/access_ee_test.go +++ b/edgraph/access_ee_test.go @@ -61,7 +61,7 @@ func TestValidateToken(t *testing.T) { for _, userdata := range userDataList { tokenString := generateJWT(userdata.namespace, userdata.userId, userdata.groupIds, expiry) ud, err := validateToken(tokenString) - require.Nil(t, err) + require.NoError(t, err) if ud.namespace != userdata.namespace || ud.userId != userdata.userId || !sliceCompare(ud.groupIds, userdata.groupIds) { @@ -103,7 +103,7 @@ func TestGetAccessJwt(t *testing.T) { for _, userdata := range userDataList { jwtstr, _ := getAccessJwt(userdata.userId, grpLst, userdata.namespace) ud, err := validateToken(jwtstr) - require.Nil(t, err) + require.NoError(t, err) if ud.namespace != userdata.namespace || ud.userId != userdata.userId || !sliceCompare(ud.groupIds, g) { t.Errorf("Actual output {%v %v %v} is not equal to the output %v generated from"+ " getAccessJwt() token", userdata.namespace, userdata.userId, grpLst, ud) @@ -121,7 +121,7 @@ func TestGetRefreshJwt(t *testing.T) { for _, userdata := range userDataList { jwtstr, _ := getRefreshJwt(userdata.userId, userdata.namespace) ud, err := validateToken(jwtstr) - require.Nil(t, err) + require.NoError(t, err) if ud.namespace != userdata.namespace || ud.userId != userdata.userId { t.Errorf("Actual output {%v %v} is not equal to the output {%v %v} generated from"+ "getRefreshJwt() token", userdata.namespace, userdata.userId, ud.namespace, ud.userId) diff --git a/ee/acl/acl_test.go b/ee/acl/acl_test.go index cda070dfc51..6bc30c55d9e 100644 --- a/ee/acl/acl_test.go +++ b/ee/acl/acl_test.go @@ -354,7 +354,7 @@ func getGrootAndGuardiansUid(t *testing.T, dg *dgo.Dgraph) (string, string) { return grootUserUid, guardiansGroupUid } -const defaultTimeToSleep = 1 * time.Second +const defaultTimeToSleep = 500 * time.Millisecond const timeout = 5 * time.Second @@ -1892,7 +1892,7 @@ func TestNewACLPredicates(t *testing.T) { tc := tc // capture range variable t.Run(tc.description, func(t *testing.T) { t.Parallel() - ctx, cancel = context.WithTimeout(context.Background(), 100*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second) defer cancel() resp, err := userClient.NewTxn().Query(ctx, tc.input) @@ -3212,7 +3212,7 @@ func TestAllowUIDAccess(t *testing.T) { ` resp, err := userClient.NewReadOnlyTxn().Query(ctx, uidQuery) - require.Nil(t, err) + require.NoError(t, err) testutil.CompareJSON(t, `{"me":[{"name":"100th User", "uid": "0x64"}]}`, string(resp.GetJson())) } diff --git a/graphql/e2e/auth/auth_test.go b/graphql/e2e/auth/auth_test.go index 75a94b82225..242b057a219 100644 --- a/graphql/e2e/auth/auth_test.go +++ b/graphql/e2e/auth/auth_test.go @@ -1059,7 +1059,7 @@ func getColID(t *testing.T, tcase TestCase) string { common.RequireNoGQLErrors(t, gqlResponse) err := json.Unmarshal(gqlResponse.Data, &result) - require.Nil(t, err) + require.NoError(t, err) if len(result.QueryColumn) > 0 { return result.QueryColumn[0].ColID @@ -1138,7 +1138,7 @@ func getProjectID(t *testing.T, tcase TestCase) string { common.RequireNoGQLErrors(t, gqlResponse) err := json.Unmarshal(gqlResponse.Data, &result) - require.Nil(t, err) + require.NoError(t, err) if len(result.QueryProject) > 0 { return result.QueryProject[0].ProjID @@ -2204,7 +2204,7 @@ func TestAuthWithSecretDirective(t *testing.T) { } err := json.Unmarshal([]byte(gqlResponse.Data), &result) - require.Nil(t, err) + require.NoError(t, err) opt := cmpopts.IgnoreFields(common.User{}, "Password") if diff := cmp.Diff(newUser, result.CheckUserPassword, opt); diff != "" { @@ -2237,7 +2237,7 @@ func TestAuthWithSecretDirective(t *testing.T) { } err = json.Unmarshal([]byte(gqlResponse.Data), &addLogResult) - require.Nil(t, err) + require.NoError(t, err) // Id of the created log logID := addLogResult.AddLog.Log[0].Id @@ -2248,7 +2248,7 @@ func TestAuthWithSecretDirective(t *testing.T) { } err = json.Unmarshal([]byte(gqlResponse.Data), &resultLog) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, resultLog.CheckLogPassword.Id, logID) diff --git a/graphql/e2e/common/query.go b/graphql/e2e/common/query.go index c9af468f4bc..ad1e10fd0b0 100644 --- a/graphql/e2e/common/query.go +++ b/graphql/e2e/common/query.go @@ -3593,7 +3593,7 @@ func checkUser(t *testing.T, userObj, expectedObj *user) { } err := json.Unmarshal([]byte(gqlResponse.Data), &result) - require.Nil(t, err) + require.NoError(t, err) opt := cmpopts.IgnoreFields(user{}, "Password") if diff := cmp.Diff(expectedObj, result.CheckUserPasword, opt); diff != "" { @@ -3620,7 +3620,7 @@ func checkUserPasswordWithAlias(t *testing.T, userObj, expectedObj *user) { } err := json.Unmarshal([]byte(gqlResponse.Data), &result) - require.Nil(t, err) + require.NoError(t, err) opt := cmpopts.IgnoreFields(user{}, "Password") if diff := cmp.Diff(expectedObj, result.CheckUserPasword, opt); diff != "" { diff --git a/graphql/e2e/subscription/subscription_test.go b/graphql/e2e/subscription/subscription_test.go index 8dc82336ced..a7461a91b4e 100644 --- a/graphql/e2e/subscription/subscription_test.go +++ b/graphql/e2e/subscription/subscription_test.go @@ -134,7 +134,7 @@ func TestSubscription(t *testing.T) { } }`, }, `{}`) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -232,7 +232,7 @@ func TestSubscriptionAuth(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -352,7 +352,7 @@ func TestSubscriptionWithAuthShouldExpireWithJWT(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -442,7 +442,7 @@ func TestSubscriptionAuthWithoutExpiry(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -504,7 +504,7 @@ func TestSubscriptionAuth_SameQueryAndClaimsButDifferentExpiry_ShouldExpireIndep } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -528,7 +528,7 @@ func TestSubscriptionAuth_SameQueryAndClaimsButDifferentExpiry_ShouldExpireIndep } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err = subscriptionClient1.RecvMsg() require.NoError(t, err) @@ -655,7 +655,7 @@ func TestSubscriptionAuth_SameQueryDifferentClaimsAndExpiry_ShouldExpireIndepend } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -701,7 +701,7 @@ func TestSubscriptionAuth_SameQueryDifferentClaimsAndExpiry_ShouldExpireIndepend } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err = subscriptionClient1.RecvMsg() require.NoError(t, err) @@ -849,7 +849,7 @@ func TestSubscriptionAuthHeaderCaseInsensitive(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -896,7 +896,7 @@ func TestSubscriptionAuth_MultiSubscriptionResponses(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) @@ -925,7 +925,7 @@ func TestSubscriptionAuth_MultiSubscriptionResponses(t *testing.T) { } }`, }, payload) - require.Nil(t, err) + require.NoError(t, err) res, err = subscriptionClient1.RecvMsg() require.NoError(t, err) @@ -1004,7 +1004,7 @@ func TestSubscriptionWithCustomDQL(t *testing.T) { } }`, }, `{}`) - require.Nil(t, err) + require.NoError(t, err) res, err := subscriptionClient.RecvMsg() require.NoError(t, err) diff --git a/graphql/resolve/auth_test.go b/graphql/resolve/auth_test.go index 9c501227ade..a4efe8c588d 100644 --- a/graphql/resolve/auth_test.go +++ b/graphql/resolve/auth_test.go @@ -308,7 +308,7 @@ func TestVerificationWithJWKUrl(t *testing.T) { ctx := metadata.NewIncomingContext(context.Background(), md) _, err = metainfo.ExtractCustomClaims(ctx) - require.Nil(t, err) + require.NoError(t, err) } func TestVerificationWithMultipleJWKUrls(t *testing.T) { @@ -360,7 +360,7 @@ func TestVerificationWithMultipleJWKUrls(t *testing.T) { require.True(t, strings.Contains(err.Error(), "unable to parse jwt token:token is unverifiable: Keyfunc returned an error")) } else { - require.Nil(t, err) + require.NoError(t, err) } }) } @@ -452,7 +452,7 @@ func queryRewriting(t *testing.T, sch string, authMeta *testutil.AuthMeta, b []b require.Equal(t, err.Error(), tcase.Error.Error()) require.Nil(t, dgQuery) } else { - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, tcase.DGQuery, dgraph.AsString(dgQuery)) } // Check for unused variables. @@ -591,14 +591,14 @@ func mutationQueryRewriting(t *testing.T, sch string, authMeta *testutil.AuthMet _, _, _ = rewriter.RewriteQueries(context.Background(), gqlMutation) _, err = rewriter.Rewrite(ctx, gqlMutation, tt.idExistence) - require.Nil(t, err) + require.NoError(t, err) // -- Act -- dgQuery, err := rewriter.FromMutationResult( ctx, gqlMutation, tt.assigned, tt.result) // -- Assert -- - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, tt.dgQuery, dgraph.AsString(dgQuery)) // Check for unused variables. diff --git a/graphql/resolve/mutation_test.go b/graphql/resolve/mutation_test.go index 2f2ce9564ab..01c789a4255 100644 --- a/graphql/resolve/mutation_test.go +++ b/graphql/resolve/mutation_test.go @@ -383,14 +383,14 @@ func TestMutationQueryRewriting(t *testing.T) { _, _, _ = rewriter.RewriteQueries(context.Background(), gqlMutation) _, err = rewriter.Rewrite(context.Background(), gqlMutation, tt.idExistence) - require.Nil(t, err) + require.NoError(t, err) // -- Act -- dgQuery, err := rewriter.FromMutationResult( context.Background(), gqlMutation, tt.assigned, tt.result) // -- Assert -- - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, tcase.DGQuery, dgraph.AsString(dgQuery)) }) } diff --git a/graphql/resolve/query_test.go b/graphql/resolve/query_test.go index 784c92d0c88..0bc388fd6e3 100644 --- a/graphql/resolve/query_test.go +++ b/graphql/resolve/query_test.go @@ -72,7 +72,7 @@ func TestQueryRewriting(t *testing.T) { gqlQuery := test.GetQuery(t, op) dgQuery, err := testRewriter.Rewrite(context.Background(), gqlQuery) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, tcase.DGQuery, dgraph.AsString(dgQuery)) }) } diff --git a/query/fastjson_test.go b/query/fastjson_test.go index 0aa72320b98..22008ac285f 100644 --- a/query/fastjson_test.go +++ b/query/fastjson_test.go @@ -37,7 +37,7 @@ func subgraphWithSingleResultAndSingleValue(val *pb.TaskValue) *SubGraph { func assertJSON(t *testing.T, expected string, sg *SubGraph) { buf, err := ToJson(context.Background(), &Latency{}, []*SubGraph{sg}, nil) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, expected, string(buf)) } diff --git a/query/outputnode_test.go b/query/outputnode_test.go index 5694250aef2..771433041a3 100644 --- a/query/outputnode_test.go +++ b/query/outputnode_test.go @@ -301,7 +301,7 @@ func TestMarshalTimeJson(t *testing.T) { for _, tc := range timesToMarshal { out, err := marshalTimeJson(tc.in) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, tc.out, string(out)) } } diff --git a/schema/parse_test.go b/schema/parse_test.go index 3329ce0fc77..b5e4c015821 100644 --- a/schema/parse_test.go +++ b/schema/parse_test.go @@ -222,7 +222,7 @@ func TestParse4_NoError(t *testing.T) { reset() result, err := Parse("name:string @index(fulltext) .") require.NotNil(t, result) - require.Nil(t, err) + require.NoError(t, err) } func TestParse5_Error(t *testing.T) { diff --git a/systest/acl/restore/acl_restore_test.go b/systest/acl/restore/acl_restore_test.go index c5cb9703a1b..aadb8cbda76 100644 --- a/systest/acl/restore/acl_restore_test.go +++ b/systest/acl/restore/acl_restore_test.go @@ -44,7 +44,7 @@ func disableDraining(t *testing.T) { client := &http.Client{} req, err := http.NewRequest("POST", testutil.AdminUrl(), bytes.NewBuffer(b)) - require.Nil(t, err) + require.NoError(t, err) req.Header.Add("content-type", "application/json") req.Header.Add("X-Dgraph-AccessToken", token.AccessJwt) diff --git a/systest/audit/audit_test.go b/systest/audit/audit_test.go index 8466b3fa1e0..2de250cf72a 100644 --- a/systest/audit/audit_test.go +++ b/systest/audit/audit_test.go @@ -123,9 +123,9 @@ input: {destination: \"/Users/sankalanparajuli/work/backup\"}) {\n response { func verifyLogs(t *testing.T, path string, cmds []string) { abs, err := filepath.Abs(path) - require.Nil(t, err) + require.NoError(t, err) f, err := os.Open(abs) - require.Nil(t, err) + require.NoError(t, err) type log struct { Msg string `json:"endpoint"` diff --git a/systest/bgindex/count_test.go b/systest/bgindex/count_test.go index e0dd3aa61aa..faee8275775 100644 --- a/systest/bgindex/count_test.go +++ b/systest/bgindex/count_test.go @@ -54,7 +54,7 @@ func TestCountIndex(t *testing.T) { dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr) return err }) - require.Nil(t, err) + require.NoError(t, err) testutil.DropAll(t, dg) if err := dg.Alter(context.Background(), &api.Operation{ Schema: "value: [string] .", diff --git a/systest/bgindex/parallel_test.go b/systest/bgindex/parallel_test.go index 30401fc83bd..2a166cb762e 100644 --- a/systest/bgindex/parallel_test.go +++ b/systest/bgindex/parallel_test.go @@ -74,7 +74,7 @@ func TestParallelIndexing(t *testing.T) { dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr) return err }) - require.Nil(t, err) + require.NoError(t, err) testutil.DropAll(t, dg) if err := dg.Alter(context.Background(), &api.Operation{ diff --git a/systest/bgindex/reverse_test.go b/systest/bgindex/reverse_test.go index e8a9393cdf2..2d0de55b823 100644 --- a/systest/bgindex/reverse_test.go +++ b/systest/bgindex/reverse_test.go @@ -48,7 +48,7 @@ func TestReverseIndex(t *testing.T) { dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr) return err }) - require.Nil(t, err) + require.NoError(t, err) testutil.DropAll(t, dg) if err := dg.Alter(context.Background(), &api.Operation{ diff --git a/systest/bgindex/string_test.go b/systest/bgindex/string_test.go index 826496ba489..d66dcd19ec5 100644 --- a/systest/bgindex/string_test.go +++ b/systest/bgindex/string_test.go @@ -53,7 +53,7 @@ func TestStringIndex(t *testing.T) { dg, err = testutil.DgraphClientWithGroot(testutil.SockAddr) return err }) - require.Nil(t, err) + require.NoError(t, err) testutil.DropAll(t, dg) if err := dg.Alter(context.Background(), &api.Operation{ diff --git a/systest/cdc/cdc_test.go b/systest/cdc/cdc_test.go index 0bc8bbbece0..a63461c8e9d 100644 --- a/systest/cdc/cdc_test.go +++ b/systest/cdc/cdc_test.go @@ -55,16 +55,16 @@ type CDCEvent struct { func verifyCDC(t *testing.T, path string) { abs, err := filepath.Abs(path) - require.Nil(t, err) + require.NoError(t, err) f, err := os.Open(abs) - require.Nil(t, err) + require.NoError(t, err) fileScanner := bufio.NewScanner(f) iter := 1 for fileScanner.Scan() { bytes := fileScanner.Bytes() l := new(CDCEvent) err := json.Unmarshal(bytes, l) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, iter, l.Value.Event.Value) iter = iter + 1 } diff --git a/tok/tok_test.go b/tok/tok_test.go index 4387392c49f..d9bc838b389 100644 --- a/tok/tok_test.go +++ b/tok/tok_test.go @@ -67,7 +67,7 @@ func TestFullTextTokenizer(t *testing.T) { require.NotNil(t, tokenizer) tokens, err := BuildTokens("Stemming works!", GetTokenizerForLang(tokenizer, "en")) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, 2, len(tokens)) id := tokenizer.Identifier() require.Equal(t, []string{encodeToken("stem", id), encodeToken("work", id)}, tokens) diff --git a/x/log_writer_test.go b/x/log_writer_test.go index ad446ff9be4..7c4eea71d55 100644 --- a/x/log_writer_test.go +++ b/x/log_writer_test.go @@ -80,44 +80,44 @@ func TestLogWriterWithEncryption(t *testing.T) { msg[1023] = '\n' for i := 0; i < 10000; i++ { n, err := lw.Write(msg) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, n, len(msg)+4, "write length is not equal") } time.Sleep(time.Second * 10) require.NoError(t, lw.Close()) file, err := os.Open(path) - require.Nil(t, err) + require.NoError(t, err) defer file.Close() outPath, _ := filepath.Abs("./log_test/audit_out.log") outfile, err := os.OpenFile(outPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) - require.Nil(t, err) + require.NoError(t, err) defer outfile.Close() block, err := aes.NewCipher(lw.EncryptionKey) - require.Nil(t, err) + require.NoError(t, err) stat, err := os.Stat(path) - require.Nil(t, err) + require.NoError(t, err) iv := make([]byte, aes.BlockSize) _, err = file.ReadAt(iv, 0) - require.Nil(t, err) + require.NoError(t, err) var iterator int64 = 16 for { content := make([]byte, binary.BigEndian.Uint32(iv[12:])) _, err = file.ReadAt(content, iterator) - require.Nil(t, err) + require.NoError(t, err) iterator = iterator + int64(binary.BigEndian.Uint32(iv[12:])) stream := cipher.NewCTR(block, iv) stream.XORKeyStream(content, content) //require.True(t, bytes.Equal(content, msg)) _, err = outfile.Write(content) - require.Nil(t, err) + require.NoError(t, err) if iterator >= stat.Size() { break } _, err = file.ReadAt(iv[12:], iterator) - require.Nil(t, err) + require.NoError(t, err) iterator = iterator + 4 } } @@ -130,7 +130,7 @@ func writeToLogWriterAndVerify(t *testing.T, lw *LogWriter, path string) { go func() { for i := 0; i < 1000; i++ { n, err := lw.Write(msg) - require.Nil(t, err) + require.NoError(t, err) require.Equal(t, n, len(msg), "write length is not equal") } }() @@ -138,7 +138,7 @@ func writeToLogWriterAndVerify(t *testing.T, lw *LogWriter, path string) { time.Sleep(time.Second * 10) require.NoError(t, lw.Close()) files, err := os.ReadDir("./log_test") - require.Nil(t, err) + require.NoError(t, err) lineCount := 0 for _, f := range files {