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

Function TestDropAll

dgraph/cmd/alpha/run_test.go:1230–1278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1228}
1229
1230func TestDropAll(t *testing.T) {
1231 var m1 = `
1232 {
1233 set{
1234 _:foo <name> "Foo" .
1235 }
1236 }`
1237 var q1 = `
1238 {
1239 q(func: allofterms(name, "Foo")) {
1240 uid
1241 name
1242 }
1243 }`
1244
1245 s := `name: string @index(term) .`
1246 require.NoError(t, alterSchemaWithRetry(s))
1247
1248 require.NoError(t, runMutation(m1))
1249
1250 output, err := runGraphqlQuery(q1)
1251 require.NoError(t, err)
1252 q1Result := map[string]interface{}{}
1253 require.NoError(t, json.Unmarshal([]byte(output), &q1Result))
1254 queryResults := q1Result["data"].(map[string]interface{})["q"].([]interface{})
1255 name := queryResults[0].(map[string]interface{})["name"].(string)
1256 require.Equal(t, "Foo", name)
1257
1258 require.NoError(t, dropAll())
1259
1260 q3 := "schema{}"
1261 output, err = runGraphqlQuery(q3)
1262 require.NoError(t, err)
1263 require.NoError(t, dgraphapi.CompareJSON(dgraphapi.GetFullSchemaHTTPResponse(dgraphapi.SchemaOptions{}), output))
1264
1265 // Reinstate schema so that we can re-run the original query.
1266 require.NoError(t, alterSchemaWithRetry(s))
1267
1268 q5 := `
1269 {
1270 q(func: allofterms(name, "Foo")) {
1271 uid
1272 name
1273 }
1274 }`
1275 output, err = runGraphqlQuery(q5)
1276 require.NoError(t, err)
1277 require.JSONEq(t, `{"data": {"q":[]}}`, output)
1278}
1279
1280func TestIllegalCountInQueryFn(t *testing.T) {
1281 s := `friend: [uid] @count .`

Callers

nothing calls this directly

Calls 6

CompareJSONFunction · 0.92
alterSchemaWithRetryFunction · 0.85
runGraphqlQueryFunction · 0.85
dropAllFunction · 0.85
runMutationFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…