From d7484b15df27f63272cfb16da2d9d962039215cf Mon Sep 17 00:00:00 2001 From: Aman Mangal Date: Mon, 13 Feb 2023 12:45:18 +0530 Subject: [PATCH] chore(linter): fix files to limit line width to 120 chars --- chunker/json_parser_test.go | 3 +- contrib/integration/bank/main.go | 3 +- dgraph/cmd/alpha/run_test.go | 10 +++-- dql/parser_test.go | 18 +++++--- edgraph/access_ee_test.go | 4 +- edgraph/server_test.go | 26 ++++++------ ee/acl/acl_test.go | 32 +++++++++----- graphql/e2e/auth/delete_mutation_test.go | 16 +++++-- graphql/e2e/auth/update_mutation_test.go | 7 +++- graphql/e2e/common/mutation.go | 20 +++++++-- graphql/e2e/common/query.go | 27 +++++++++--- graphql/e2e/common/subscription.go | 4 +- graphql/e2e/custom_logic/cmd/main.go | 8 +++- graphql/e2e/custom_logic/custom_logic_test.go | 42 ++++++++++--------- graphql/e2e/schema/schema_test.go | 8 +++- graphql/e2e/subscription/subscription_test.go | 4 +- graphql/resolve/auth_test.go | 8 +++- graphql/schema/wrappers_test.go | 16 ++++--- .../profiling/graphql_profiler.go | 3 +- lex/iri_test.go | 6 ++- query/query.go | 13 ++++-- raftwal/storage_test.go | 9 ++-- systest/backup/minio-large/backup_test.go | 3 +- systest/backup/minio/backup_test.go | 3 +- systest/backup/nfs-backup/backup_test.go | 18 +++++--- systest/mutations_test.go | 3 +- systest/online-restore/online_restore_test.go | 18 ++++++-- t/t.go | 9 ++-- testutil/graphql.go | 4 +- tlstest/mtls_internal/ha_6_node/ha_test.go | 3 +- types/conversion_test.go | 11 +++-- types/geofilter_test.go | 23 +++++++++- types/sort_test.go | 3 +- worker/mutation_test.go | 19 +++++++-- x/file_test.go | 16 ++++++- 35 files changed, 297 insertions(+), 123 deletions(-) diff --git a/chunker/json_parser_test.go b/chunker/json_parser_test.go index 7a328852edb..3ad2eb0262d 100644 --- a/chunker/json_parser_test.go +++ b/chunker/json_parser_test.go @@ -396,7 +396,8 @@ func TestJsonNumberParsing(t *testing.T) { out *api.Value }{ {`{"uid": "1", "key": 9223372036854775299}`, &api.Value{Val: &api.Value_IntVal{IntVal: 9223372036854775299}}}, - {`{"uid": "1", "key": 9223372036854775299.0}`, &api.Value{Val: &api.Value_DoubleVal{DoubleVal: 9223372036854775299.0}}}, + {`{"uid": "1", "key": 9223372036854775299.0}`, + &api.Value{Val: &api.Value_DoubleVal{DoubleVal: 9223372036854775299.0}}}, {`{"uid": "1", "key": 27670116110564327426}`, nil}, {`{"uid": "1", "key": "23452786"}`, &api.Value{Val: &api.Value_StrVal{StrVal: "23452786"}}}, {`{"uid": "1", "key": "23452786.2378"}`, &api.Value{Val: &api.Value_StrVal{StrVal: "23452786.2378"}}}, diff --git a/contrib/integration/bank/main.go b/contrib/integration/bank/main.go index 0c6896002ed..ced360cf80e 100644 --- a/contrib/integration/bank/main.go +++ b/contrib/integration/bank/main.go @@ -268,7 +268,8 @@ func (s *state) runTransaction(dg *dgo.Dgraph, buf *bytes.Buffer) error { return err } if len(assigned.GetUids()) > 0 { - fmt.Fprintf(w, "[StartTs: %v] CREATED K_%02d: %+v for %+v\n", assigned.Txn.StartTs, dst.Key, assigned.GetUids(), dst) + fmt.Fprintf(w, "[StartTs: %v] CREATED K_%02d: %+v for %+v\n", assigned.Txn.StartTs, + dst.Key, assigned.GetUids(), dst) for _, uid := range assigned.GetUids() { dst.Uid = uid } diff --git a/dgraph/cmd/alpha/run_test.go b/dgraph/cmd/alpha/run_test.go index 9d0d13b1f62..a54a6de25a2 100644 --- a/dgraph/cmd/alpha/run_test.go +++ b/dgraph/cmd/alpha/run_test.go @@ -248,9 +248,9 @@ func TestDeletePredicate(t *testing.T) { output, err = runGraphqlQuery(`schema{}`) require.NoError(t, err) - testutil.CompareJSON(t, testutil.GetFullSchemaHTTPResponse(testutil.SchemaOptions{UserPreds: `{"predicate":"age","type":"default"},` + - `{"predicate":"name","type":"string","index":true, "tokenizer":["term"]}`}), - output) + testutil.CompareJSON(t, testutil.GetFullSchemaHTTPResponse(testutil.SchemaOptions{ + UserPreds: `{"predicate":"age","type":"default"},` + + `{"predicate":"name","type":"string","index":true, "tokenizer":["term"]}`}), output) output, err = runGraphqlQuery(q1) require.NoError(t, err) @@ -1142,7 +1142,9 @@ func TestDeleteAllSP2(t *testing.T) { output, err := runGraphqlQuery(q) require.NoError(t, err) - require.JSONEq(t, `{"data": {"me":[{"name":"July 3 2017","date":"2017-07-03T03:49:03Z","weight":262.3,"lifeLoad":5,"stressLevel":3}]}}`, output) + require.JSONEq(t, + `{"data": {"me":[{"name":"July 3 2017","date":"2017-07-03T03:49:03Z",`+ + `"weight":262.3,"lifeLoad":5,"stressLevel":3}]}}`, output) m = fmt.Sprintf(` { diff --git a/dql/parser_test.go b/dql/parser_test.go index 861607950c7..8ea34efafdd 100644 --- a/dql/parser_test.go +++ b/dql/parser_test.go @@ -2378,7 +2378,8 @@ func TestParseFilter_opNot2(t *testing.T) { require.NotNil(t, res.Query[0]) require.Equal(t, []string{"friends", "gender", "age", "hometown"}, childAttrs(res.Query[0])) require.Equal(t, []string{"name"}, childAttrs(res.Query[0].Children[0])) - require.Equal(t, `(AND (NOT (OR (a aa "aaa") (b bb "bbb"))) (c cc "ccc"))`, res.Query[0].Children[0].Filter.debugString()) + require.Equal(t, `(AND (NOT (OR (a aa "aaa") (b bb "bbb"))) (c cc "ccc"))`, + res.Query[0].Children[0].Filter.debugString()) } // Test operator precedence. Let brackets make or evaluates before and. @@ -2421,9 +2422,11 @@ func TestParseFilter_brac(t *testing.T) { require.NotNil(t, res.Query[0]) require.Equal(t, []string{"friends", "gender", "age", "hometown"}, childAttrs(res.Query[0])) require.Equal(t, []string{"name"}, childAttrs(res.Query[0].Children[0])) - require.Equal(t, + require.Equal( + t, `(OR (a name "hello") (AND (AND (b name "world" "is") (OR (c aa "aaa") (OR (d dd "haha") (e ee "aaa")))) (f ff "aaa")))`, - res.Query[0].Children[0].Filter.debugString()) + res.Query[0].Children[0].Filter.debugString(), + ) } // Test if unbalanced brac will lead to errors. @@ -2479,7 +2482,11 @@ func TestParseFilter_Geo2(t *testing.T) { ` resp, err := Parse(Request{Str: query}) require.NoError(t, err) - require.Equal(t, "[[11.2,-2.234],[-31.23,4.3214],[5.312,6.53]]", resp.Query[0].Children[0].Filter.Func.Args[0].Value) + require.Equal( + t, + "[[11.2,-2.234],[-31.23,4.3214],[5.312,6.53]]", + resp.Query[0].Children[0].Filter.Func.Args[0].Value, + ) } func TestParseFilter_Geo3(t *testing.T) { @@ -4234,7 +4241,8 @@ func TestParserFuzz(t *testing.T) { t.Run(test.name, func(t *testing.T) { defer func() { if r := recover(); r != nil { - t.Errorf("parser panic caused by test: '%s', input: '%s': %v\n%s", test.name, test.in, r, debug.Stack()) + t.Errorf("parser panic caused by test: '%s', input: '%s': %v\n%s", test.name, + test.in, r, debug.Stack()) } }() diff --git a/edgraph/access_ee_test.go b/edgraph/access_ee_test.go index 970d7b49b6a..adad07eb563 100644 --- a/edgraph/access_ee_test.go +++ b/edgraph/access_ee_test.go @@ -62,7 +62,9 @@ func TestValidateToken(t *testing.T) { tokenString := generateJWT(userdata.namespace, userdata.userId, userdata.groupIds, expiry) ud, err := validateToken(tokenString) require.Nil(t, err) - if ud.namespace != userdata.namespace || ud.userId != userdata.userId || !sliceCompare(ud.groupIds, userdata.groupIds) { + if ud.namespace != userdata.namespace || ud.userId != userdata.userId || + !sliceCompare(ud.groupIds, userdata.groupIds) { + t.Errorf("Actual output %+v is not equal to the expected output %+v", userdata, ud) } } diff --git a/edgraph/server_test.go b/edgraph/server_test.go index 0ce00d6686a..11cb892568f 100644 --- a/edgraph/server_test.go +++ b/edgraph/server_test.go @@ -100,21 +100,21 @@ func TestValidateKeys(t *testing.T) { nquad string noError bool }{ - {name: "test 1", nquad: `_:alice "stuff" ( "key 1" = 12 ) .`, noError: false}, - {name: "test 2", nquad: `_:alice "stuff" ( "key 1" = 12 ) .`, noError: false}, - {name: "test 3", nquad: `_:alice "stuff" ( ~key1 = 12 ) .`, noError: false}, - {name: "test 4", nquad: `_:alice "stuff" ( "~key1" = 12 ) .`, noError: false}, - {name: "test 5", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`, noError: false}, - {name: "test 6", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`, noError: false}, - {name: "test 7", nquad: `_:alice <~knows> "stuff" ( key1 = 12 ) .`, noError: false}, - {name: "test 8", nquad: `_:alice <~knows> "stuff" ( "key1" = 12 ) .`, noError: false}, - {name: "test 9", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`, noError: false}, - {name: "test 10", nquad: `_:alice "stuff" ( key1 = 12 , "key 2" = 13 ) .`, noError: false}, - {name: "test 11", nquad: `_:alice "stuff" ( "key1" = 12, key2 = 13 , "key 3" = "a b" ) .`, noError: false}, - {name: "test 12", nquad: `_:alice "stuff" ( key1 = 12 ) .`, noError: false}, + {name: "test 1", nquad: `_:alice "stuff" ( "key 1" = 12 ) .`}, + {name: "test 2", nquad: `_:alice "stuff" ( "key 1" = 12 ) .`}, + {name: "test 3", nquad: `_:alice "stuff" ( ~key1 = 12 ) .`}, + {name: "test 4", nquad: `_:alice "stuff" ( "~key1" = 12 ) .`}, + {name: "test 5", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`}, + {name: "test 6", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`}, + {name: "test 7", nquad: `_:alice <~knows> "stuff" ( key1 = 12 ) .`}, + {name: "test 8", nquad: `_:alice <~knows> "stuff" ( "key1" = 12 ) .`}, + {name: "test 9", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`}, + {name: "test 10", nquad: `_:alice "stuff" ( key1 = 12 , "key 2" = 13 ) .`}, + {name: "test 11", nquad: `_:alice "stuff" ( "key1" = 12, key2 = 13 , "key 3" = "a b" ) .`}, + {name: "test 12", nquad: `_:alice "stuff" ( key1 = 12 ) .`}, {name: "test 13", nquad: `_:alice "stuff" ( key1 = 12 ) .`, noError: true}, {name: "test 14", nquad: `_:alice "stuff" .`, noError: true}, - {name: "test 15", nquad: `_:alice "stuff" .`, noError: false}, + {name: "test 15", nquad: `_:alice "stuff" .`}, } for _, tc := range tests { diff --git a/ee/acl/acl_test.go b/ee/acl/acl_test.go index 0a3e11295ce..5f629e2a5bc 100644 --- a/ee/acl/acl_test.go +++ b/ee/acl/acl_test.go @@ -38,7 +38,9 @@ var ( userpassword = "simplepassword" ) -func makeRequestAndRefreshTokenIfNecessary(t *testing.T, token *testutil.HttpToken, params testutil.GraphQLParams) *testutil.GraphQLResponse { +func makeRequestAndRefreshTokenIfNecessary(t *testing.T, token *testutil.HttpToken, + params testutil.GraphQLParams) *testutil.GraphQLResponse { + resp := testutil.MakeGQLRequestWithAccessJwt(t, ¶ms, token.AccessJwt) if len(resp.Errors) == 0 || !strings.Contains(resp.Errors.Error(), "Token is expired") { return resp @@ -55,6 +57,7 @@ func makeRequestAndRefreshTokenIfNecessary(t *testing.T, token *testutil.HttpTok token.RefreshToken = newtoken.RefreshToken return testutil.MakeGQLRequestWithAccessJwt(t, ¶ms, token.AccessJwt) } + func createUser(t *testing.T, token *testutil.HttpToken, username, password string) *testutil.GraphQLResponse { addUser := ` mutation addUser($name: String!, $pass: String!) { @@ -103,7 +106,9 @@ func checkUserCount(t *testing.T, resp []byte, expected int) { require.Equal(t, expected, len(r.AddUser.User)) } -func deleteUser(t *testing.T, token *testutil.HttpToken, username string, confirmDeletion bool) *testutil.GraphQLResponse { +func deleteUser(t *testing.T, token *testutil.HttpToken, username string, + confirmDeletion bool) *testutil.GraphQLResponse { + delUser := ` mutation deleteUser($name: String!) { deleteUser(filter: {name: {eq: $name}}) { @@ -1279,7 +1284,8 @@ func TestExpandQueryWithACLPermissions(t *testing.T) { // Test that groot has access to all the predicates resp, err := dg.NewReadOnlyTxn().Query(ctx, query) require.NoError(t, err, "Error while querying data") - testutil.CompareJSON(t, `{"me":[{"name":"RandomGuy","age":23, "nickname":"RG"},{"name":"RandomGuy2","age":25, "nickname":"RG2"}]}`, + testutil.CompareJSON(t, + `{"me":[{"name":"RandomGuy","age":23, "nickname":"RG"},{"name":"RandomGuy2","age":25, "nickname":"RG2"}]}`, string(resp.GetJson())) userClient, err := testutil.DgraphClient(testutil.SockAddr) @@ -1334,7 +1340,8 @@ func TestExpandQueryWithACLPermissions(t *testing.T) { addRulesToGroup(t, token, devGroup, []rule{{"age", Write.Code}, {"name", Read.Code}, {"nickname", Read.Code}}) testutil.PollTillPassOrTimeout(t, userClient, query, - `{"me":[{"name":"RandomGuy","age":23, "nickname":"RG"},{"name":"RandomGuy2","age":25, "nickname":"RG2"}]}`, timeout) + `{"me":[{"name":"RandomGuy","age":23, "nickname":"RG"},{"name":"RandomGuy2","age":25, "nickname":"RG2"}]}`, + timeout) } func TestDeleteQueryWithACLPermissions(t *testing.T) { @@ -1396,8 +1403,11 @@ func TestDeleteQueryWithACLPermissions(t *testing.T) { // Test that groot has access to all the predicates resp, err = dg.NewReadOnlyTxn().Query(ctx, query) require.NoError(t, err, "Error while querying data") - testutil.CompareJSON(t, `{"q1":[{"name":"RandomGuy","age":23, "nickname": "RG"},{"name":"RandomGuy2","age":25, "nickname": "RG2"}]}`, - string(resp.GetJson())) + testutil.CompareJSON( + t, + `{"q1":[{"name":"RandomGuy","age":23, "nickname": "RG"},{"name":"RandomGuy2","age":25, "nickname": "RG2"}]}`, + string(resp.GetJson()), + ) // Give Write Access to alice for name and age predicate addRulesToGroup(t, token, devGroup, []rule{{"name", Write.Code}, {"age", Write.Code}}) @@ -1508,8 +1518,9 @@ func TestValQueryWithACLPermissions(t *testing.T) { // Test that groot has access to all the predicates resp, err := dg.NewReadOnlyTxn().Query(ctx, query) require.NoError(t, err, "Error while querying data") - testutil.CompareJSON(t, `{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],"q2":[{"val(v)":"RandomGuy","val(a)":23}]}`, - string(resp.GetJson())) + testutil.CompareJSON(t, + `{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],`+ + `"q2":[{"val(v)":"RandomGuy","val(a)":23}]}`, string(resp.GetJson())) // All test cases tests := []struct { @@ -1733,8 +1744,9 @@ func TestAllPredsPermission(t *testing.T) { // Test that groot has access to all the predicates resp, err := dg.NewReadOnlyTxn().Query(ctx, query) require.NoError(t, err, "Error while querying data") - testutil.CompareJSON(t, `{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],"q2":[{"val(v)":"RandomGuy","val(a)":23}]}`, - string(resp.GetJson())) + testutil.CompareJSON(t, + `{"q1":[{"name":"RandomGuy","age":23},{"name":"RandomGuy2","age":25}],`+ + `"q2":[{"val(v)":"RandomGuy","val(a)":23}]}`, string(resp.GetJson())) // All test cases tests := []struct { diff --git a/graphql/e2e/auth/delete_mutation_test.go b/graphql/e2e/auth/delete_mutation_test.go index f935273540a..6fcb5d2011c 100644 --- a/graphql/e2e/auth/delete_mutation_test.go +++ b/graphql/e2e/auth/delete_mutation_test.go @@ -132,7 +132,8 @@ func (f *FbPost) add(t *testing.T, user, role string) { } } `, - Variables: map[string]interface{}{"text": f.Text, "id1": f.Author.Id, "id2": f.Sender.Id, "id3": f.Receiver.Id, "postCount": f.PostCount, "pwd": "password"}, + Variables: map[string]interface{}{"text": f.Text, "id1": f.Author.Id, "id2": f.Sender.Id, + "id3": f.Receiver.Id, "postCount": f.PostCount, "pwd": "password"}, } gqlResponse := getParams.ExecuteAsPost(t, common.GraphqlURL) common.RequireNoGQLErrors(t, gqlResponse) @@ -205,13 +206,19 @@ func TestAuth_DeleteOnInterfaceWithAuthRules(t *testing.T) { for _, tcase := range testCases { // Fetch all the types implementing `Post` interface. - allQuestions, allAnswers, allFbPosts, allPostsIds := getAllPosts(t, []string{"user1@dgraph.io", "user2@dgraph.io"}, []string{"ADMIN"}, []bool{true, false}) + allQuestions, allAnswers, allFbPosts, allPostsIds := getAllPosts(t, + []string{"user1@dgraph.io", "user2@dgraph.io"}, []string{"ADMIN"}, []bool{true, false}) require.True(t, len(allQuestions) == 3) require.True(t, len(allAnswers) == 2) require.True(t, len(allFbPosts) == 2) require.True(t, len(allPostsIds) == 7) - deleteQuestions, deleteAnswers, deleteFbPosts, _ := getAllPosts(t, []string{tcase.user}, []string{tcase.role}, []bool{tcase.ans}) + deleteQuestions, deleteAnswers, deleteFbPosts, _ := getAllPosts( + t, + []string{tcase.user}, + []string{tcase.role}, + []bool{tcase.ans}, + ) params := &common.GraphQLParams{ Headers: common.GetJWTForInterfaceAuth(t, tcase.user, tcase.role, tcase.ans, metaInfo), @@ -321,7 +328,8 @@ func TestAuth_DeleteOnTypeWithGraphTraversalAuthRuleOnInterface(t *testing.T) { for _, tcase := range testCases { t.Run(tcase.user+strconv.FormatBool(tcase.ans), func(t *testing.T) { // Get all Question ids. - _, allQuestionsIds := getAllQuestions(t, []string{"user1@dgraph.io", "user2@dgraph.io"}, []bool{true, false}) + _, allQuestionsIds := getAllQuestions(t, + []string{"user1@dgraph.io", "user2@dgraph.io"}, []bool{true, false}) require.True(t, len(allQuestionsIds) == 3) deleteQuestions, _ := getAllQuestions(t, []string{tcase.user}, []bool{tcase.ans}) diff --git a/graphql/e2e/auth/update_mutation_test.go b/graphql/e2e/auth/update_mutation_test.go index e3dd1099167..d35b151492c 100644 --- a/graphql/e2e/auth/update_mutation_test.go +++ b/graphql/e2e/auth/update_mutation_test.go @@ -165,7 +165,9 @@ func getAllQuestions(t *testing.T, users []string, answers []bool) ([]*Question, return questions, keys } -func getAllPosts(t *testing.T, users []string, roles []string, answers []bool) ([]*Question, []*Answer, []*FbPost, []string) { +func getAllPosts(t *testing.T, users []string, roles []string, answers []bool) ( + []*Question, []*Answer, []*FbPost, []string) { + Questions, getAllQuestionIds := getAllQuestions(t, users, answers) Answers, getAllAnswerIds := getAllAnswers(t, users) FbPosts, getAllFbPostIds := getAllFbPosts(t, users, roles) @@ -428,7 +430,8 @@ func getAllLogs(t *testing.T, users, roles []string) ([]*Log, []string) { } func TestAuth_UpdateOnInterfaceWithAuthRules(t *testing.T) { - _, _, _, ids := getAllPosts(t, []string{"user1@dgraph.io", "user2@dgraph.io"}, []string{"ADMIN"}, []bool{true, false}) + _, _, _, ids := getAllPosts(t, []string{"user1@dgraph.io", "user2@dgraph.io"}, + []string{"ADMIN"}, []bool{true, false}) testCases := []TestCase{{ name: "Only 2 nodes satisfy auth rules with the given values and hence should be updated", user: "user1@dgraph.io", diff --git a/graphql/e2e/common/mutation.go b/graphql/e2e/common/mutation.go index fd2525095dc..4cda009d398 100644 --- a/graphql/e2e/common/mutation.go +++ b/graphql/e2e/common/mutation.go @@ -4117,7 +4117,15 @@ func intWithList(t *testing.T) { } } }`, - variables: map[string]interface{}{"post1": []interface{}{map[string]interface{}{"title": "Dgraph", "commentsByMonth": []int{2, 33, 11, 6}, "likesByMonth": []int64{4, 33, 1, 66}}}}, + variables: map[string]interface{}{ + "post1": []interface{}{ + map[string]interface{}{ + "title": "Dgraph", + "commentsByMonth": []int{2, 33, 11, 6}, + "likesByMonth": []int64{4, 33, 1, 66}, + }, + }, + }, expected: `{ "addpost1": { @@ -5513,7 +5521,9 @@ func inputCoerciontoList(t *testing.T) { author1DeleteFilter := map[string]interface{}{"name": map[string]interface{}{"in": []string{"Jack", "Jackob"}}} DeleteGqlType(t, "author1", author1DeleteFilter, 2, nil) - posts1DeleteFilter := map[string]interface{}{"title": map[string]interface{}{"in": []string{"Dgraph", "GraphQL", "RDBMS", "DB"}}} + posts1DeleteFilter := map[string]interface{}{ + "title": map[string]interface{}{"in": []string{"Dgraph", "GraphQL", "RDBMS", "DB"}}, + } DeleteGqlType(t, "post1", posts1DeleteFilter, 4, nil) } @@ -5984,8 +5994,10 @@ func upsertMutationTests(t *testing.T) { } gqlResponse = addStateParams.ExecuteAsPost(t, GraphqlURL) require.NotNil(t, gqlResponse.Errors) - require.Equal(t, "couldn't rewrite mutation addState because failed to rewrite mutation payload because id S1 already exists for field xcode inside type State", - gqlResponse.Errors[0].Error()) + require.Equal(t, + "couldn't rewrite mutation addState because failed to rewrite mutation payload because id S1 already exists for field xcode inside type State", + gqlResponse.Errors[0].Error(), + ) // Add Mutation with upsert true should succeed. It should link the state to // existing country diff --git a/graphql/e2e/common/query.go b/graphql/e2e/common/query.go index 5b237dd8cbd..1e83e049619 100644 --- a/graphql/e2e/common/query.go +++ b/graphql/e2e/common/query.go @@ -430,10 +430,14 @@ func entitiesQueryWithKeyFieldOfTypeString(t *testing.T) { JSONEqGraphQL(t, expectedJSON, string(entitiesResp.Data)) - spaceShipDeleteFilter := map[string]interface{}{"id": map[string]interface{}{"in": []string{"SpaceShip1", "SpaceShip2", "SpaceShip3", "SpaceShip4"}}} + spaceShipDeleteFilter := map[string]interface{}{ + "id": map[string]interface{}{"in": []string{"SpaceShip1", "SpaceShip2", "SpaceShip3", "SpaceShip4"}}, + } DeleteGqlType(t, "SpaceShip", spaceShipDeleteFilter, 4, nil) - missionDeleteFilter := map[string]interface{}{"id": map[string]interface{}{"in": []string{"Mission1", "Mission2", "Mission3", "Mission4"}}} + missionDeleteFilter := map[string]interface{}{ + "id": map[string]interface{}{"in": []string{"Mission1", "Mission2", "Mission3", "Mission4"}}, + } DeleteGqlType(t, "Mission", missionDeleteFilter, 4, nil) } @@ -486,7 +490,9 @@ func entitiesQueryWithKeyFieldOfTypeInt(t *testing.T) { planetDeleteFilter := map[string]interface{}{"id": map[string]interface{}{"in": []int{1, 2, 3, 4}}} DeleteGqlType(t, "Planet", planetDeleteFilter, 4, nil) - missionDeleteFilter := map[string]interface{}{"id": map[string]interface{}{"in": []string{"Mission1", "Mission2", "Mission3", "Mission4"}}} + missionDeleteFilter := map[string]interface{}{ + "id": map[string]interface{}{"in": []string{"Mission1", "Mission2", "Mission3", "Mission4"}}, + } DeleteGqlType(t, "Mission", missionDeleteFilter, 4, nil) } @@ -2518,7 +2524,11 @@ func queryWithCascade(t *testing.T) { } } }`, - variables: map[string]interface{}{"ids": authorIds, "fieldsRoot": []string{"reputation", "name"}, "fieldsDeep": []string{"text"}}, + variables: map[string]interface{}{ + "ids": authorIds, + "fieldsRoot": []string{"reputation", "name"}, + "fieldsDeep": []string{"text"}, + }, respData: `{ "queryAuthor": [ { @@ -3118,7 +3128,10 @@ func persistedQuery(t *testing.T) { // test get method as well queryCountryParams.Extensions = nil - gqlResponse = queryCountryParams.ExecuteAsGet(t, GraphqlURL+`?extensions={"persistedQuery":{"sha256Hash":"bbc0af44f82ce5c38e775f7f14c71e5eba1936b12b3e66c452ee262ef147f1ed"}}`) + gqlResponse = queryCountryParams.ExecuteAsGet( + t, + GraphqlURL+`?extensions={"persistedQuery":{"sha256Hash":"bbc0af44f82ce5c38e775f7f14c71e5eba1936b12b3e66c452ee262ef147f1ed"}}`, + ) RequireNoGQLErrors(t, gqlResponse) } @@ -3763,7 +3776,9 @@ func queryFilterWithIDInputCoercion(t *testing.T) { } } }`, - variables: map[string]interface{}{"filter": map[string]interface{}{"id": []int{cast.ToInt(authors[0].ID), cast.ToInt(authors[1].ID)}}}, + variables: map[string]interface{}{ + "filter": map[string]interface{}{"id": []int{cast.ToInt(authors[0].ID), cast.ToInt(authors[1].ID)}}, + }, respData: `{ "queryAuthor": [ { diff --git a/graphql/e2e/common/subscription.go b/graphql/e2e/common/subscription.go index 888c9787376..81ab6f3ae1a 100644 --- a/graphql/e2e/common/subscription.go +++ b/graphql/e2e/common/subscription.go @@ -59,7 +59,9 @@ type GraphQLSubscriptionClient struct { } // NewGraphQLSubscription returns graphql subscription client. -func NewGraphQLSubscription(url string, req *schema.Request, subscriptionPayload string) (*GraphQLSubscriptionClient, error) { +func NewGraphQLSubscription(url string, req *schema.Request, subscriptionPayload string) ( + *GraphQLSubscriptionClient, error) { + header := http.Header{ "Sec-WebSocket-Protocol": []string{protocolGraphQLWS}, } diff --git a/graphql/e2e/custom_logic/cmd/main.go b/graphql/e2e/custom_logic/cmd/main.go index f631eee3080..c9155fdb853 100644 --- a/graphql/e2e/custom_logic/cmd/main.go +++ b/graphql/e2e/custom_logic/cmd/main.go @@ -115,7 +115,9 @@ func commonGraphqlHandler(handlerName string) func(w http.ResponseWriter, r *htt if err != nil { log.Fatal(err) } - if req.Query == strings.TrimSpace(graphqlResponses[handlerName].Request) && string(req.Variables) == strings.TrimSpace(graphqlResponses[handlerName].Variables) { + if req.Query == strings.TrimSpace(graphqlResponses[handlerName].Request) && + string(req.Variables) == strings.TrimSpace(graphqlResponses[handlerName].Variables) { + fmt.Fprintf(w, graphqlResponses[handlerName].Response) return } @@ -276,7 +278,9 @@ func getFavMoviesErrorHandler(w http.ResponseWriter, r *http.Request) { return } - getRestError(w, []byte(`{"errors":[{"message": "Rest API returns Error for myFavoriteMovies query","locations": [ { "line": 5, "column": 4 } ],"path": ["Movies","name"]}]}`)) + getRestError(w, []byte( + `{"errors":[{"message": "Rest API returns Error for myFavoriteMovies query",`+ + `"locations": [ { "line": 5, "column": 4 } ],"path": ["Movies","name"]}]}`)) } func getFavMoviesHandler(w http.ResponseWriter, r *http.Request) { diff --git a/graphql/e2e/custom_logic/custom_logic_test.go b/graphql/e2e/custom_logic/custom_logic_test.go index 77f4a3677e8..d1295bca9f7 100644 --- a/graphql/e2e/custom_logic/custom_logic_test.go +++ b/graphql/e2e/custom_logic/custom_logic_test.go @@ -200,9 +200,9 @@ func TestCustomQueryShouldForwardHeaders(t *testing.T) { params := &common.GraphQLParams{ Query: query, Headers: map[string][]string{ - "X-App-Token": []string{"app-token"}, - "X-User-Id": []string{"123"}, - "Random-header": []string{"random"}, + "X-App-Token": {"app-token"}, + "X-User-Id": {"123"}, + "Random-header": {"random"}, }, } @@ -238,9 +238,9 @@ func TestCustomNameForwardHeaders(t *testing.T) { params := &common.GraphQLParams{ Query: query, Headers: map[string][]string{ - "App": []string{"app-token"}, - "X-User-Id": []string{"123"}, - "Random-header": []string{"random"}, + "App": {"app-token"}, + "X-User-Id": {"123"}, + "Random-header": {"random"}, }, } @@ -2618,7 +2618,7 @@ func TestCustomDQL(t *testing.T) { } } """) - + dqlTweetsByAuthorFollowers: [Tweets] @custom(dql: """ query { var(func: type(Tweets)) @filter(anyoftext(Tweets.text, "DQL")) { @@ -2634,7 +2634,7 @@ func TestCustomDQL(t *testing.T) { } } """) - + filteredTweetsByAuthorFollowers(search: String!): [Tweets] @custom(dql: """ query t($search: string) { var(func: type(Tweets)) @filter(anyoftext(Tweets.text, $search)) { @@ -2814,9 +2814,13 @@ func TestCustomDQL(t *testing.T) { ] }`, string(result.Data)) - userFilter := map[string]interface{}{"screen_name": map[string]interface{}{"in": []string{"minhaj", "pawan", "abhimanyu"}}} + userFilter := map[string]interface{}{ + "screen_name": map[string]interface{}{"in": []string{"minhaj", "pawan", "abhimanyu"}}, + } common.DeleteGqlType(t, "User", userFilter, 3, nil) - tweetFilter := map[string]interface{}{"text": map[string]interface{}{"in": []string{"Hello DQL!", "Woah DQL works!", "hmm, It worked.", "Nice."}}} + tweetFilter := map[string]interface{}{ + "text": map[string]interface{}{"in": []string{"Hello DQL!", "Woah DQL works!", "hmm, It worked.", "Nice."}}, + } common.DeleteGqlType(t, "Tweets", tweetFilter, 4, nil) } @@ -2859,7 +2863,7 @@ func TestCustomGetQuerywithRESTError(t *testing.T) { func TestCustomFieldsWithRestError(t *testing.T) { schema := ` type Car @remote { - id: ID! + id: ID! name: String! } @@ -2883,7 +2887,7 @@ func TestCustomFieldsWithRestError(t *testing.T) { body: "{uid: $id}" mode: BATCH, } - ) + ) } ` @@ -2931,7 +2935,7 @@ func TestCustomFieldsWithRestError(t *testing.T) { "age": 10, "cars": { "name": "car-0x1" - } + } } ] }` @@ -3005,7 +3009,7 @@ func TestCustomResolverInInterfaceImplFrag(t *testing.T) { id: ID! name: String! @id } - + type Human implements Character { totalCredits: Int bio: String @custom(http: { @@ -3079,23 +3083,23 @@ func TestCustomFieldIsResolvedWhenNoModeGiven(t *testing.T) { skipIntrospection: true, }) } - + type Blueprint { blueprintId: String! @id shallowProducts: [ItemType] deepProducts: [BlueprintProduct] } - + type BlueprintProduct { itemType: ItemType amount: Int } - + type MarketStats { typeId: String! @id - price: Float + price: Float } - + type MarketStatsR @remote { typeId: String price: Float diff --git a/graphql/e2e/schema/schema_test.go b/graphql/e2e/schema/schema_test.go index 4653ca4bcd9..42dc0911f52 100644 --- a/graphql/e2e/schema/schema_test.go +++ b/graphql/e2e/schema/schema_test.go @@ -505,8 +505,12 @@ func TestGQLSchemaValidate(t *testing.T) { f1: String! @dgraph(pred:"~movie") } `, - errors: x.GqlErrorList{{Message: "input:3: Type X; Field id: has the @dgraph directive but fields of type ID can't have the @dgraph directive."}, {Message: "input:7: Type Y; Field f1 is of type String, but reverse predicate in @dgraph directive only applies to fields with object types."}}, - valid: false, + errors: x.GqlErrorList{ + {Message: "input:3: Type X; Field id: has the @dgraph directive " + + "but fields of type ID can't have the @dgraph directive."}, + {Message: "input:7: Type Y; Field f1 is of type String, " + + "but reverse predicate in @dgraph directive only applies to fields with object types."}}, + valid: false, }, } diff --git a/graphql/e2e/subscription/subscription_test.go b/graphql/e2e/subscription/subscription_test.go index 886065ca40a..3ecf4c277e6 100644 --- a/graphql/e2e/subscription/subscription_test.go +++ b/graphql/e2e/subscription/subscription_test.go @@ -1043,7 +1043,9 @@ func TestSubscriptionWithCustomDQL(t *testing.T) { common.RequireNoGQLErrors(t, &subscriptionResp) // Check the latest update. - require.JSONEq(t, `{"queryUserTweetCounts":[{"screen_name":"001","tweetCount": 2},{"screen_name":"002","tweetCount": 1}]}`, string(subscriptionResp.Data)) + require.JSONEq(t, + `{"queryUserTweetCounts":[{"screen_name":"001","tweetCount": 2},{"screen_name":"002","tweetCount": 1}]}`, + string(subscriptionResp.Data)) require.Contains(t, subscriptionResp.Extensions, touchedUidskey) require.Greater(t, int(subscriptionResp.Extensions[touchedUidskey].(float64)), 0) diff --git a/graphql/resolve/auth_test.go b/graphql/resolve/auth_test.go index 658a94b98cf..6867c5ae8e6 100644 --- a/graphql/resolve/auth_test.go +++ b/graphql/resolve/auth_test.go @@ -327,7 +327,10 @@ func TestVerificationWithMultipleJWKUrls(t *testing.T) { require.Equal(t, metainfo.Namespace, "https://xyz.io/jwt/claims") require.Equal(t, metainfo.VerificationKey, "") require.Equal(t, metainfo.JWKUrl, "") - require.Equal(t, metainfo.JWKUrls, []string{"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com", "https://dev-hr2kugfp.us.auth0.com/.well-known/jwks.json"}) + require.Equal(t, metainfo.JWKUrls, + []string{"https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com", + "https://dev-hr2kugfp.us.auth0.com/.well-known/jwks.json"}, + ) testCases := []struct { name string @@ -353,7 +356,8 @@ func TestVerificationWithMultipleJWKUrls(t *testing.T) { _, err := metainfo.ExtractCustomClaims(ctx) if tcase.invalid { - require.True(t, strings.Contains(err.Error(), "unable to parse jwt token:token is unverifiable: Keyfunc returned an error")) + require.True(t, strings.Contains(err.Error(), + "unable to parse jwt token:token is unverifiable: Keyfunc returned an error")) } else { require.Nil(t, err) } diff --git a/graphql/schema/wrappers_test.go b/graphql/schema/wrappers_test.go index e50e4f1997e..618b9ed2ee4 100644 --- a/graphql/schema/wrappers_test.go +++ b/graphql/schema/wrappers_test.go @@ -1051,7 +1051,9 @@ func TestCustomLogicHeaders(t *testing.T) { ) } `, - errors.New("input:13: Type Query; Field user; introspectionHeaders in @custom directive should use secrets to store the header value. " + "To do that specify `Api-Token` in this format '#Dgraph.Secret name value' at the bottom of your schema file." + "\n"), + errors.New("input:13: Type Query; Field user; introspectionHeaders in @custom directive should use " + + "secrets to store the header value. " + "To do that specify `Api-Token` in this format " + + "'#Dgraph.Secret name value' at the bottom of your schema file." + "\n"), }, { "check for secret and forward headers overlapping", @@ -1073,7 +1075,8 @@ func TestCustomLogicHeaders(t *testing.T) { ) } `, - errors.New("input:14: Type Query; Field user; secretHeaders and forwardHeaders in @custom directive cannot have overlapping headers, found: `Authorization`." + "\n"), + errors.New("input:14: Type Query; Field user; secretHeaders and forwardHeaders in @custom directive " + + "cannot have overlapping headers, found: `Authorization`." + "\n"), }, { "check for header structure", @@ -1095,7 +1098,8 @@ func TestCustomLogicHeaders(t *testing.T) { ) } `, - errors.New("input:14: Type Query; Field user; secretHeaders in @custom directive should be of the form 'remote_headername:local_headername' or just 'headername', found: `Authorization:Auth:random`." + "\n"), + errors.New("input:14: Type Query; Field user; secretHeaders in @custom directive should be of the form " + + "'remote_headername:local_headername' or just 'headername', found: `Authorization:Auth:random`.\n"), }, } for _, test := range tcases { @@ -1199,7 +1203,8 @@ func TestParseSecrets(t *testing.T) { nil, "", nil, - errors.New("input: Invalid `Dgraph.Authorization` format: # Dgraph.Authorization X-Test-Dgraph https://dgraph.io/jwt/claims \"key\""), + errors.New("input: Invalid `Dgraph.Authorization` format: # Dgraph.Authorization X-Test-Dgraph " + + "https://dgraph.io/jwt/claims \"key\""), }, { "should throw an error if multiple authorization values are specified", @@ -1231,7 +1236,8 @@ func TestParseSecrets(t *testing.T) { nil, "", nil, - errors.New("required field missing in Dgraph.Authorization: `Verification key`/`JWKUrl`/`JWKUrls` `Algo` `Header` `Namespace`"), + errors.New("required field missing in Dgraph.Authorization: " + + "`Verification key`/`JWKUrl`/`JWKUrls` `Algo` `Header` `Namespace`"), }, { "Should be able to parse Dgraph.Authorization irrespective of spacing between # and Dgraph.Authorization", diff --git a/graphql/testdata/custom_bench/profiling/graphql_profiler.go b/graphql/testdata/custom_bench/profiling/graphql_profiler.go index 7608cee6f91..ff10cb14a32 100644 --- a/graphql/testdata/custom_bench/profiling/graphql_profiler.go +++ b/graphql/testdata/custom_bench/profiling/graphql_profiler.go @@ -694,7 +694,8 @@ func saveBenchmarkStats(queryFiles []os.DirEntry, respDataSizes []int, avgStats } var strBuilder strings.Builder - strBuilder.WriteString(`|===================================================================================================================================================================================================================================================================| + strBuilder.WriteString(` +|===================================================================================================================================================================================================================================================================| | QueryFile Name | len(data) (bytes) | Avg Round Trip Time (RTT) | Avg Total Time (TT) | Avg Trace Time (TrT) | Avg Dgraph Time (DT) | Avg GraphQL Time (GT=TT-DT) | Avg % GraphQL Time (GT/TT*100) | Avg Tracing Error (TT-TrT) | Avg Round Trip Overhead (RTT-TT) | |================|===================|===========================|=====================|======================|======================|=============================|================================|============================|==================================|`) diff --git a/lex/iri_test.go b/lex/iri_test.go index 65ba0368091..d2d8c42041c 100644 --- a/lex/iri_test.go +++ b/lex/iri_test.go @@ -29,7 +29,8 @@ type testCase struct { func TestHasUChars(t *testing.T) { l := &Lexer{} - testInputs := []testCase{{"u1def", true}, {"UADEFABCD", true}, {"uYDQW", false}, {"Uydvxypqt", false}, {"abc", false}, {"uabcdg", true}} + testInputs := []testCase{{"u1def", true}, {"UADEFABCD", true}, + {"uYDQW", false}, {"Uydvxypqt", false}, {"abc", false}, {"uabcdg", true}} for _, test := range testInputs { l.Reset(test.input) r := l.Next() @@ -62,7 +63,8 @@ func TestIsHex(t *testing.T) { } func TestIsIRIRefChar(t *testing.T) { - testInputs := []testCase{{"\\u1def", true}, {"\\UADEFABCD", true}, {"A", true}, {"a", true}, {"<", false}, {">", false}, {"{", false}, {"`", false}, {" ", false}, {"\\abc", false}} + testInputs := []testCase{{"\\u1def", true}, {"\\UADEFABCD", true}, {"A", true}, {"a", true}, + {"<", false}, {">", false}, {"{", false}, {"`", false}, {" ", false}, {"\\abc", false}} l := &Lexer{} for _, test := range testInputs { l.Reset(test.input) diff --git a/query/query.go b/query/query.go index 33238fb03eb..3bf5202431d 100644 --- a/query/query.go +++ b/query/query.go @@ -1387,9 +1387,12 @@ func (sg *SubGraph) populateVarMap(doneVars map[string]varValue, sgPath []*SubGr child.updateUidMatrix() // Apply pagination after the @cascade. - if len(child.Params.Cascade.Fields) > 0 && (child.Params.Cascade.First != 0 || child.Params.Cascade.Offset != 0) { + if len(child.Params.Cascade.Fields) > 0 && + (child.Params.Cascade.First != 0 || child.Params.Cascade.Offset != 0) { + for i := 0; i < len(child.uidMatrix); i++ { - start, end := x.PageRange(child.Params.Cascade.First, child.Params.Cascade.Offset, len(child.uidMatrix[i].Uids)) + start, end := x.PageRange(child.Params.Cascade.First, + child.Params.Cascade.Offset, len(child.uidMatrix[i].Uids)) child.uidMatrix[i].Uids = child.uidMatrix[i].Uids[start:end] } } @@ -2083,7 +2086,8 @@ func ProcessGraph(ctx context.Context, sg, parent *SubGraph, rch chan error) { }) } if sg.Params.AfterUID > 0 { - i := sort.Search(len(sg.DestUIDs.Uids), func(i int) bool { return sg.DestUIDs.Uids[i] > sg.Params.AfterUID }) + i := sort.Search(len(sg.DestUIDs.Uids), + func(i int) bool { return sg.DestUIDs.Uids[i] > sg.Params.AfterUID }) sg.DestUIDs.Uids = sg.DestUIDs.Uids[i:] } @@ -2881,7 +2885,8 @@ func (req *Request) ProcessQuery(ctx context.Context) (err error) { if len(sg.Params.Cascade.Fields) > 0 && (sg.Params.Cascade.First != 0 || sg.Params.Cascade.Offset != 0) { sg.updateUidMatrix() for i := 0; i < len(sg.uidMatrix); i++ { - start, end := x.PageRange(sg.Params.Cascade.First, sg.Params.Cascade.Offset, len(sg.uidMatrix[i].Uids)) + start, end := x.PageRange(sg.Params.Cascade.First, + sg.Params.Cascade.Offset, len(sg.uidMatrix[i].Uids)) sg.uidMatrix[i].Uids = sg.uidMatrix[i].Uids[start:end] } } diff --git a/raftwal/storage_test.go b/raftwal/storage_test.go index b43921bab39..e0d8859037f 100644 --- a/raftwal/storage_test.go +++ b/raftwal/storage_test.go @@ -119,10 +119,13 @@ func TestStorageEntries(t *testing.T) { // limit to 2 {4, 7, uint64(ents[1].Size() + ents[2].Size()), nil, []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}}, // limit to 2 - {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()/2), nil, []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}}, - {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size() - 1), nil, []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}}, + {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()/2), nil, + []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}}, + {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size() - 1), nil, + []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}}}, // all - {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()), nil, []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}}, + {4, 7, uint64(ents[1].Size() + ents[2].Size() + ents[3].Size()), nil, + []raftpb.Entry{{Index: 4, Term: 4}, {Index: 5, Term: 5}, {Index: 6, Term: 6}}}, } for i, tt := range tests { diff --git a/systest/backup/minio-large/backup_test.go b/systest/backup/minio-large/backup_test.go index eb7d693258e..a41179a6c48 100644 --- a/systest/backup/minio-large/backup_test.go +++ b/systest/backup/minio-large/backup_test.go @@ -55,7 +55,8 @@ var ( // Test to add a large database and verify backup and restore work as expected. func TestBackupMinioLarge(t *testing.T) { // backupDestination = "minio://" + testutil.DockerPrefix + "_minio_1:9001/dgraph-backup?secure=false" - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) ctx := context.Background() diff --git a/systest/backup/minio/backup_test.go b/systest/backup/minio/backup_test.go index d45f41c656f..ff331b404e0 100644 --- a/systest/backup/minio/backup_test.go +++ b/systest/backup/minio/backup_test.go @@ -57,7 +57,8 @@ func TestBackupMinio(t *testing.T) { addr := testutil.ContainerAddr("minio", 9001) localBackupDst = "minio://" + addr + "/dgraph-backup?secure=false" - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) diff --git a/systest/backup/nfs-backup/backup_test.go b/systest/backup/nfs-backup/backup_test.go index ecbc2830ac2..61c4f62b204 100644 --- a/systest/backup/nfs-backup/backup_test.go +++ b/systest/backup/nfs-backup/backup_test.go @@ -48,15 +48,19 @@ var ( func TestBackupHAClust(t *testing.T) { - backupRestoreTest(t, testutil.SockAddr, testutil.SockAddrAlpha4Http, testutil.SockAddrZeroHttp, backupDstHA, testutil.SockAddrHttp) + backupRestoreTest(t, testutil.SockAddr, testutil.SockAddrAlpha4Http, + testutil.SockAddrZeroHttp, backupDstHA, testutil.SockAddrHttp) } func TestBackupNonHAClust(t *testing.T) { - backupRestoreTest(t, testutil.SockAddrAlpha7, testutil.SockAddrAlpha8Http, testutil.SockAddrZero7Http, backupDstNonHA, testutil.SockAddrAlpha7Http) + backupRestoreTest(t, testutil.SockAddrAlpha7, testutil.SockAddrAlpha8Http, + testutil.SockAddrZero7Http, backupDstNonHA, testutil.SockAddrAlpha7Http) } -func backupRestoreTest(t *testing.T, backupAlphaSocketAddr string, restoreAlphaAddr string, backupZeroAddr string, backupDst string, backupAlphaSocketAddrHttp string) { +func backupRestoreTest(t *testing.T, backupAlphaSocketAddr string, restoreAlphaAddr string, + backupZeroAddr string, backupDst string, backupAlphaSocketAddrHttp string) { + conn, err := grpc.Dial(backupAlphaSocketAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) @@ -204,7 +208,9 @@ func checkObjectCount(t *testing.T, expectedCount int, restoreAlphaAddr string) require.Equal(t, expectedCount, int(movieCount)) } -func runBackup(t *testing.T, numExpectedFiles, numExpectedDirs int, backupAlphaSocketAddrHttp string, backupDst string) []string { +func runBackup(t *testing.T, numExpectedFiles, numExpectedDirs int, + backupAlphaSocketAddrHttp string, backupDst string) []string { + return runBackupInternal(t, false, numExpectedFiles, numExpectedDirs, backupAlphaSocketAddrHttp, backupDst) } @@ -257,7 +263,9 @@ func runBackupInternal(t *testing.T, forceFull bool, numExpectedFiles, return dirs } -func restore(t *testing.T, lastDir string, restoreAlphaAddr string, backupDst string, backupType string, backupNum int) string { +func restore(t *testing.T, lastDir string, restoreAlphaAddr string, + backupDst string, backupType string, backupNum int) string { + var restoreRequest string if backupType != "incremental" { restoreRequest = `mutation restore($loc: String!) { diff --git a/systest/mutations_test.go b/systest/mutations_test.go index 3d25f8752b9..bb4f538f56b 100644 --- a/systest/mutations_test.go +++ b/systest/mutations_test.go @@ -817,7 +817,8 @@ func ListToScalar(t *testing.T, c *dgo.Dgraph) { err := c.Alter(ctx, &api.Operation{Schema: `pred: string @index(exact) .`}) require.Error(t, err) - require.Contains(t, err.Error(), `Type can't be changed from list to scalar for attr: [pred] without dropping it first.`) + require.Contains(t, err.Error(), + `Type can't be changed from list to scalar for attr: [pred] without dropping it first.`) require.NoError(t, c.Alter(ctx, &api.Operation{DropAttr: `pred`})) op = &api.Operation{Schema: `pred: string @index(exact) .`} diff --git a/systest/online-restore/online_restore_test.go b/systest/online-restore/online_restore_test.go index eadc5770268..6c5d2ccb0b0 100644 --- a/systest/online-restore/online_restore_test.go +++ b/systest/online-restore/online_restore_test.go @@ -198,7 +198,8 @@ func runMutations(t *testing.T, dg *dgo.Dgraph) { func TestBasicRestore(t *testing.T) { disableDraining(t) - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial(testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) @@ -222,7 +223,10 @@ func TestBasicRestore(t *testing.T) { func TestRestoreBackupNum(t *testing.T) { disableDraining(t) - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial( + testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t))), + ) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) @@ -239,7 +243,10 @@ func TestRestoreBackupNum(t *testing.T) { func TestRestoreBackupNumInvalid(t *testing.T) { disableDraining(t) - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial( + testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t))), + ) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) @@ -296,7 +303,10 @@ func TestRestoreBackupNumInvalid(t *testing.T) { func TestMoveTablets(t *testing.T) { disableDraining(t) - conn, err := grpc.Dial(testutil.SockAddr, grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t)))) + conn, err := grpc.Dial( + testutil.SockAddr, + grpc.WithTransportCredentials(credentials.NewTLS(testutil.GetAlphaClientConfig(t))), + ) require.NoError(t, err) dg := dgo.NewDgraphClient(api.NewDgraphClient(conn)) diff --git a/t/t.go b/t/t.go index eac722a832f..1d6e84cff53 100644 --- a/t/t.go +++ b/t/t.go @@ -224,20 +224,21 @@ func stopCluster(composeFile, prefix string, wg *sync.WaitGroup, err error) { err = testutil.DockerCpFromContainer(c.ID, workDir+"/coverage.out", tmp) if err != nil { - fmt.Printf("error while bringing down cluster. Failed at copying coverage file. Prefix: %s. Error: %v\n", + fmt.Printf("error bringing down cluster. Failed at copying coverage file. Prefix: %s. Error: %v\n", prefix, err) } if err = appendTestCoverageFile(tmp, coverageFile); err != nil { - fmt.Printf("Error while bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n", - prefix, err) + fmt.Printf("error bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n", + prefix, err, + ) } os.Remove(tmp) coverageBulk := strings.Replace(composeFile, "docker-compose.yml", "coverage_bulk.out", -1) if err = appendTestCoverageFile(coverageBulk, coverageFile); err != nil { - fmt.Printf("Error while bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n", + fmt.Printf("Error bringing down cluster. Failed at appending coverage file. Prefix: %s. Error: %v\n", prefix, err) } } diff --git a/testutil/graphql.go b/testutil/graphql.go index 9aef733b45c..cfb3c8edf08 100644 --- a/testutil/graphql.go +++ b/testutil/graphql.go @@ -92,7 +92,9 @@ func MakeGQLRequestWithAccessJwt(t *testing.T, params *GraphQLParams, accessToke return MakeGQLRequestWithAccessJwtAndTLS(t, params, nil, accessToken) } -func MakeGQLRequestWithAccessJwtAndTLS(t *testing.T, params *GraphQLParams, tls *tls.Config, accessToken string) *GraphQLResponse { +func MakeGQLRequestWithAccessJwtAndTLS(t *testing.T, params *GraphQLParams, + tls *tls.Config, accessToken string) *GraphQLResponse { + var adminUrl string if tls != nil { adminUrl = "https://" + SockAddrHttp + "/admin" diff --git a/tlstest/mtls_internal/ha_6_node/ha_test.go b/tlstest/mtls_internal/ha_6_node/ha_test.go index 77fc2296b02..c78908d7524 100644 --- a/tlstest/mtls_internal/ha_6_node/ha_test.go +++ b/tlstest/mtls_internal/ha_6_node/ha_test.go @@ -134,7 +134,8 @@ func getClientForAlpha(t *testing.T, name string) *dgo.Dgraph { } tlsConf, err := x.GenerateClientTLSConfig(c) require.NoError(t, err) - dgConn, err := grpc.Dial(testutil.ContainerAddr(name, 9080), grpc.WithTransportCredentials(credentials.NewTLS(tlsConf))) + dgConn, err := grpc.Dial(testutil.ContainerAddr(name, 9080), + grpc.WithTransportCredentials(credentials.NewTLS(tlsConf))) require.NoError(t, err) client := dgo.NewDgraphClient(api.NewDgraphClient(dgConn)) return client diff --git a/types/conversion_test.go b/types/conversion_test.go index d57d927be28..120a7b28b1f 100644 --- a/types/conversion_test.go +++ b/types/conversion_test.go @@ -240,7 +240,8 @@ func TestConvertToBinary(t *testing.T) { {in: Val{BinaryID, []byte("2016")}, out: []byte("2016")}, {in: Val{IntID, bs(int64(3))}, out: bs(int64(3))}, {in: Val{FloatID, bs(float64(-3.5))}, out: bs(float64(-3.5))}, - {in: Val{DateTimeID, bs(time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))}, out: bs(time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))}, + {in: Val{DateTimeID, bs(time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))}, + out: bs(time.Date(2006, 01, 02, 15, 04, 05, 0, time.UTC))}, } for _, tc := range tests { @@ -265,7 +266,8 @@ func TestConvertFromBinary(t *testing.T) { {in: []byte(""), out: Val{BinaryID, []byte("")}}, {in: []byte("hello"), out: Val{StringID, "hello"}}, {in: []byte(""), out: Val{StringID, ""}}, - {in: bs(time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)), out: Val{DateTimeID, time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)}}, + {in: bs(time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)), + out: Val{DateTimeID, time.Date(2016, 1, 1, 0, 0, 0, 0, time.UTC)}}, {in: bs(time.Time{}), out: Val{DateTimeID, time.Time{}}}, } @@ -723,7 +725,7 @@ func TestConvertStringToFloat(t *testing.T) { {in: "1", out: float64(1)}, {in: "13816.251", out: float64(13816.251)}, {in: "-1221.12", out: float64(-1221.12)}, - {in: "-0.0", out: float64(-0.0)}, + {in: "-0.0", out: float64(0.0)}, {in: "1e10", out: float64(1e10)}, {in: "1e-2", out: float64(0.01)}, { @@ -840,7 +842,8 @@ func TestConvertToString(t *testing.T) { {in: Val{Tid: BoolID, Value: bs(true)}, out: "true"}, {in: Val{Tid: StringID, Value: []byte("srfrog")}, out: "srfrog"}, {in: Val{Tid: PasswordID, Value: []byte("password")}, out: "password"}, - {in: Val{Tid: DateTimeID, Value: bs(time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC))}, out: "2006-01-02T15:04:05Z"}, + {in: Val{Tid: DateTimeID, Value: bs(time.Date(2006, time.January, 2, 15, 4, 5, 0, time.UTC))}, + out: "2006-01-02T15:04:05Z"}, } for _, tc := range tests { diff --git a/types/geofilter_test.go b/types/geofilter_test.go index a3adb2d9891..9f05167ac82 100644 --- a/types/geofilter_test.go +++ b/types/geofilter_test.go @@ -331,11 +331,30 @@ func TestMatchesFilterIntersectsPolygon(t *testing.T) { // These two polygons don't intersect. polyOut := geom.NewPolygon(geom.XY).MustSetCoords([][]geom.Coord{ - {{-122.4989104270935, 37.736953437345356}, {-122.50504732131958, 37.729096212099975}, {-122.49515533447264, 37.732049133202324}, {-122.4989104270935, 37.736953437345356}}, + { + {-122.4989104270935, 37.736953437345356}, + {-122.50504732131958, 37.729096212099975}, + {-122.49515533447264, 37.732049133202324}, + {-122.4989104270935, 37.736953437345356}, + }, }) poly2 := geom.NewPolygon(geom.XY).MustSetCoords([][]geom.Coord{ - {{-122.5033039, 37.7334601}, {-122.503128, 37.7335189}, {-122.5031222, 37.7335205}, {-122.5030813, 37.7335868}, {-122.5031511, 37.73359}, {-122.5031933, 37.7335916}, {-122.5032228, 37.7336022}, {-122.5032697, 37.7335937}, {-122.5033194, 37.7335874}, {-122.5033723, 37.7335518}, {-122.503369, 37.7335068}, {-122.5033462, 37.7334474}, {-122.5033039, 37.7334601}}, + { + {-122.5033039, 37.7334601}, + {-122.503128, 37.7335189}, + {-122.5031222, 37.7335205}, + {-122.5030813, 37.7335868}, + {-122.5031511, 37.73359}, + {-122.5031933, 37.7335916}, + {-122.5032228, 37.7336022}, + {-122.5032697, 37.7335937}, + {-122.5033194, 37.7335874}, + {-122.5033723, 37.7335518}, + {-122.503369, 37.7335068}, + {-122.5033462, 37.7334474}, + {-122.5033039, 37.7334601}, + }, }) data = formDataPolygon(t, polyOut) _, qd, err = queryTokens(QueryTypeIntersects, data, 0.0) diff --git a/types/sort_test.go b/types/sort_test.go index b1bb6329350..0d578f7d135 100644 --- a/types/sort_test.go +++ b/types/sort_test.go @@ -158,7 +158,8 @@ func TestEqual(t *testing.T) { "equal should return false when either parameter cannot have its value converted") require.False(t, equal(Val{Tid: IntID}, Val{Tid: IntID, Value: int64(3)}), "equal should return false when either parameter cannot have its value converted") - require.False(t, equal(Val{Tid: IntID}, Val{Tid: IntID}), "equal should return false when either parameter cannot have its value converted") + require.False(t, equal(Val{Tid: IntID}, Val{Tid: IntID}), + "equal should return false when either parameter cannot have its value converted") // not equal when there is a type mismatch between value and tid for either parameter require.False(t, equal(Val{Tid: IntID, Value: float64(3.0)}, Val{Tid: FloatID, Value: float64(3.0)}), diff --git a/worker/mutation_test.go b/worker/mutation_test.go index c5bbdb2c8d0..76dd7638846 100644 --- a/worker/mutation_test.go +++ b/worker/mutation_test.go @@ -176,13 +176,26 @@ func TestCheckSchema(t *testing.T) { require.Error(t, checkSchema(s1)) // reverse on non-uid type - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_STRING, Directive: pb.SchemaUpdate_REVERSE} + s1 = &pb.SchemaUpdate{ + Predicate: x.GalaxyAttr("name"), + ValueType: pb.Posting_STRING, + Directive: pb.SchemaUpdate_REVERSE, + } require.Error(t, checkSchema(s1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("name"), ValueType: pb.Posting_FLOAT, Directive: pb.SchemaUpdate_INDEX, Tokenizer: []string{"term"}} + s1 = &pb.SchemaUpdate{ + Predicate: x.GalaxyAttr("name"), + ValueType: pb.Posting_FLOAT, + Directive: pb.SchemaUpdate_INDEX, + Tokenizer: []string{"term"}, + } require.NoError(t, checkSchema(s1)) - s1 = &pb.SchemaUpdate{Predicate: x.GalaxyAttr("friend"), ValueType: pb.Posting_UID, Directive: pb.SchemaUpdate_REVERSE} + s1 = &pb.SchemaUpdate{ + Predicate: x.GalaxyAttr("friend"), + ValueType: pb.Posting_UID, + Directive: pb.SchemaUpdate_REVERSE, + } require.NoError(t, checkSchema(s1)) // Schema with internal predicate. diff --git a/x/file_test.go b/x/file_test.go index 414fafb135a..36aec46d4a4 100644 --- a/x/file_test.go +++ b/x/file_test.go @@ -35,8 +35,20 @@ func TestFindDataFiles(t *testing.T) { defer deleteDirs(t, dir[1]) validTestFiles := filepath.Join(filepath.Dir(thisFile), "test-files-valid") invalidTestFiles := filepath.Join(filepath.Dir(thisFile), "test-files-invalid") - expectedFilesArray := []string{"test-files-valid/test-2.rdf.gz", "test-files-valid/test-3.json", "test-files-valid/test-4.json.gz"} - file_data := [7]string{"test-1.txt", "test-2.rdf.gz", "test-3.json", "test-4.json.gz", "test-5.txt", "test-6.txt.gz", "test-7.go"} + expectedFilesArray := []string{ + "test-files-valid/test-2.rdf.gz", + "test-files-valid/test-3.json", + "test-files-valid/test-4.json.gz", + } + file_data := [7]string{ + "test-1.txt", + "test-2.rdf.gz", + "test-3.json", + "test-4.json.gz", + "test-5.txt", + "test-6.txt.gz", + "test-7.go", + } for i, data := range file_data { var filePath string