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

Function TestParseSchemaFromAlterOperation

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

Source from the content-addressed store, hash-verified

125}
126
127func TestParseSchemaFromAlterOperation(t *testing.T) {
128 md := metadata.New(map[string]string{"namespace": "123"})
129 ctx := metadata.NewIncomingContext(context.Background(), md)
130 dir := t.TempDir()
131 ps, err := badger.OpenManaged(badger.DefaultOptions(dir))
132 x.Check(err)
133 defer ps.Close()
134 schema.Init(ps)
135
136 tests := []struct {
137 name string
138 schema string
139 noError bool
140 }{
141 {
142 name: "test no duplicate predicates and types",
143 schema: `
144 name: string @index(fulltext, term) .
145 age: int @index(int) @upsert .
146 friend: [uid] @count @reverse .
147 `,
148 noError: true,
149 },
150 {
151 name: "test duplicate predicates error",
152 schema: `
153 name: string @index(fulltext, term) .
154 age: int @index(int) @upsert .
155 friend: [uid] @count @reverse .
156 friend: [uid] @count @reverse .
157 `,
158 noError: false,
159 },
160 {
161 name: "test duplicate predicates error 2",
162 schema: `
163 name: string @index(fulltext, term) .
164 age: int @index(int) @upsert .
165 friend: [uid] @count @reverse .
166 friend: int @index(int) @count @reverse .
167 `,
168 noError: false,
169 },
170 {
171 name: "test duplicate types error",
172 schema: `
173 name: string .
174 age: int .
175 type Person {
176 name
177 }
178 type Person {
179 age
180 }
181 `,
182 noError: false,
183 },
184 }

Callers

nothing calls this directly

Calls 7

CheckFunction · 0.92
InitFunction · 0.92
makeOpFunction · 0.85
CloseMethod · 0.65
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected