MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / TestValidateKeys

Function TestValidateKeys

edgraph/server_test.go:89–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestValidateKeys(t *testing.T) {
90 tests := []struct {
91 name string
92 nquad string
93 noError bool
94 }{
95 {name: "test 1", nquad: `_:alice <knows> "stuff" ( "key 1" = 12 ) .`},
96 {name: "test 2", nquad: `_:alice <knows> "stuff" ( "key 1" = 12 ) .`},
97 {name: "test 3", nquad: `_:alice <knows> "stuff" ( ~key1 = 12 ) .`},
98 {name: "test 4", nquad: `_:alice <knows> "stuff" ( "~key1" = 12 ) .`},
99 {name: "test 5", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`},
100 {name: "test 6", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`},
101 {name: "test 7", nquad: `_:alice <~knows> "stuff" ( key1 = 12 ) .`},
102 {name: "test 8", nquad: `_:alice <~knows> "stuff" ( "key1" = 12 ) .`},
103 {name: "test 9", nquad: `_:alice <~knows> "stuff" ( "key 1" = 12 ) .`},
104 {name: "test 10", nquad: `_:alice <knows> "stuff" ( key1 = 12 , "key 2" = 13 ) .`},
105 {name: "test 11", nquad: `_:alice <knows> "stuff" ( "key1" = 12, key2 = 13 , "key 3" = "a b" ) .`},
106 {name: "test 12", nquad: `_:alice <knows~> "stuff" ( key1 = 12 ) .`},
107 {name: "test 13", nquad: `_:alice <knows> "stuff" ( key1 = 12 ) .`, noError: true},
108 {name: "test 14", nquad: `_:alice <knows@some> "stuff" .`, noError: true},
109 {name: "test 15", nquad: `_:alice <knows@some@en> "stuff" .`},
110 }
111
112 for _, tc := range tests {
113 t.Run(tc.name, func(t *testing.T) {
114 nq, _, err := chunker.ParseRDFs([]byte(tc.nquad))
115 require.NoError(t, err)
116
117 err = validateKeys(nq[0])
118 if tc.noError {
119 require.NoError(t, err, "Unexpected error for: %+v", nq)
120 } else {
121 require.Error(t, err, "Expected an error: %+v", nq)
122 }
123 })
124 }
125}
126
127func TestParseSchemaFromAlterOperation(t *testing.T) {
128 md := metadata.New(map[string]string{"namespace": "123"})

Callers

nothing calls this directly

Calls 4

ParseRDFsFunction · 0.92
validateKeysFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…