MCPcopy
hub / github.com/dgraph-io/dgraph / addTeachers

Function addTeachers

graphql/e2e/custom_logic/custom_logic_test.go:541–570  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

539}
540
541func addTeachers(t *testing.T) []*teacher {
542 addTeacherParams := &common.GraphQLParams{
543 Query: `mutation {
544 addTeacher(input: [{ age: 28 }, { age: 27 }, { age: 26 }]) {
545 teacher {
546 tid
547 age
548 }
549 }
550 }`,
551 }
552
553 result := addTeacherParams.ExecuteAsPost(t, common.GraphqlURL)
554 common.RequireNoGQLErrors(t, result)
555
556 var res struct {
557 AddTeacher struct {
558 Teacher []*teacher
559 }
560 }
561 require.NoError(t, json.Unmarshal([]byte(result.Data), &res))
562
563 require.Equal(t, len(res.AddTeacher.Teacher), 3)
564
565 // sort in descending order
566 sort.Slice(res.AddTeacher.Teacher, func(i, j int) bool {
567 return res.AddTeacher.Teacher[i].Age > res.AddTeacher.Teacher[j].Age
568 })
569 return res.AddTeacher.Teacher
570}
571
572type school struct {
573 ID string `json:"id,omitempty"`

Callers 1

Calls 3

ExecuteAsPostMethod · 0.95
RequireNoGQLErrorsFunction · 0.92
SliceMethod · 0.80

Tested by

no test coverage detected