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

Function TestSchemaIndexCustom

schema/parse_test.go:186–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184`
185
186func TestSchemaIndexCustom(t *testing.T) {
187 require.NoError(t, ParseBytes([]byte(schemaIndexVal5), 1))
188 checkSchema(t, State().predicate, []nameType{
189 {x.AttrInRootNamespace("name"), &pb.SchemaUpdate{
190 Predicate: x.AttrInRootNamespace("name"),
191 ValueType: pb.Posting_STRING,
192 Tokenizer: []string{"exact"},
193 Directive: pb.SchemaUpdate_INDEX,
194 Count: true,
195 }},
196 {x.AttrInRootNamespace("address"), &pb.SchemaUpdate{
197 Predicate: x.AttrInRootNamespace("address"),
198 ValueType: pb.Posting_STRING,
199 Tokenizer: []string{"term"},
200 Directive: pb.SchemaUpdate_INDEX,
201 }},
202 {x.AttrInRootNamespace("age"), &pb.SchemaUpdate{
203 Predicate: x.AttrInRootNamespace("age"),
204 ValueType: pb.Posting_INT,
205 Tokenizer: []string{"int"},
206 Directive: pb.SchemaUpdate_INDEX,
207 }},
208 {x.AttrInRootNamespace("friend"), &pb.SchemaUpdate{
209 ValueType: pb.Posting_UID,
210 Predicate: x.AttrInRootNamespace("friend"),
211 Directive: pb.SchemaUpdate_REVERSE,
212 Count: true,
213 List: true,
214 }},
215 })
216 require.True(t, State().IsIndexed(context.Background(), x.AttrInRootNamespace("name")))
217 require.False(t, State().IsReversed(context.Background(), x.AttrInRootNamespace("name")))
218 require.Equal(t, "int", State().Tokenizer(context.Background(), x.AttrInRootNamespace("age"))[0].Name())
219}
220
221func TestParse(t *testing.T) {
222 reset()

Callers

nothing calls this directly

Calls 8

AttrInRootNamespaceFunction · 0.92
ParseBytesFunction · 0.85
IsIndexedMethod · 0.80
IsReversedMethod · 0.80
TokenizerMethod · 0.80
checkSchemaFunction · 0.70
StateFunction · 0.70
NameMethod · 0.65

Tested by

no test coverage detected