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

Function TestDebugSupport

dgraph/cmd/alpha/http_test.go:721–813  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

719}
720
721func TestDebugSupport(t *testing.T) {
722 require.NoError(t, dropAll())
723 require.NoError(t, alterSchema(`name: string @index(term) .`))
724
725 m1 := `
726 {
727 set {
728 _:a <name> "Alice" .
729 _:b <name> "Bob" .
730 _:c <name> "Charlie" .
731 _:d <name> "David" .
732 _:e <name> "Emily" .
733 _:f <name> "Frank" .
734 _:g <name> "Gloria" .
735 }
736 }
737 `
738 require.NoError(t, runMutation(m1))
739
740 q1 := `
741 {
742 users(func: has(name), orderasc: name) {
743 name
744 }
745 }
746 `
747
748 requireEqual := func(t *testing.T, data string) {
749 var r struct {
750 Data struct {
751 Users []struct {
752 Name string `json:"name"`
753 UID string `json:"uid"`
754 } `json:"users"`
755 } `json:"data"`
756 }
757 if err := json.Unmarshal([]byte(data), &r); err != nil {
758 require.NoError(t, err)
759 }
760
761 exp := []string{"Alice", "Bob", "Charlie", "David", "Emily", "Frank", "Gloria"}
762 actual := make([]string, 0, len(exp))
763 for _, u := range r.Data.Users {
764 actual = append(actual, u.Name)
765 require.NotEmpty(t, u.UID, "uid should be nonempty in debug mode")
766 }
767 sort.Strings(actual)
768 require.Equal(t, exp, actual)
769 }
770
771 data, resp, err := queryWithGz(q1, "application/dql", "true", "", false, false)
772 require.NoError(t, err)
773 requireEqual(t, data)
774 require.Empty(t, resp.Header.Get("Content-Encoding"))
775
776 data, resp, err = queryWithGz(q1, "application/dql", "true", "", false, true)
777 require.NoError(t, err)
778 requireEqual(t, data)

Callers

nothing calls this directly

Calls 7

dropAllFunction · 0.85
alterSchemaFunction · 0.85
queryWithGzFunction · 0.85
requireDeadlineFunction · 0.85
queryWithTsFunction · 0.85
runMutationFunction · 0.70
GetMethod · 0.65

Tested by

no test coverage detected