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

Function TestMutationAndQueryButNoUpsert

dgraph/cmd/alpha/upsert_test.go:2228–2258  ·  view source on GitHub ↗

This mutation (upsert) has one independent query and one independent mutation.

(t *testing.T)

Source from the content-addressed store, hash-verified

2226
2227// This mutation (upsert) has one independent query and one independent mutation.
2228func TestMutationAndQueryButNoUpsert(t *testing.T) {
2229 require.NoError(t, dropAll())
2230 require.NoError(t, alterSchema(`
2231email: string @index(exact) .
2232works_for: string @index(exact) .
2233works_with: [uid] .`))
2234
2235 m1 := `
2236upsert {
2237 query {
2238 q(func: eq(works_for, "company1")) {
2239 uid
2240 name
2241 }
2242 }
2243
2244 mutation {
2245 set {
2246 _:user1 <name> "user1" .
2247 _:user1 <email> "user1@company1.io" .
2248 _:user1 <works_for> "company1" .
2249 }
2250 }
2251}`
2252 mr, err := mutationWithTs(mutationInp{body: m1, typ: "application/rdf", commitNow: true})
2253 require.NoError(t, err)
2254 result := QueryResult{}
2255 require.NoError(t, json.Unmarshal(mr.data, &result))
2256 require.Equal(t, 0, len(result.Queries["q"]))
2257 require.Equal(t, []string{"email", "name", "works_for"}, splitPreds(mr.preds))
2258}
2259
2260func TestMultipleMutation(t *testing.T) {
2261 require.NoError(t, dropAll())

Callers

nothing calls this directly

Calls 4

dropAllFunction · 0.85
alterSchemaFunction · 0.85
mutationWithTsFunction · 0.85
splitPredsFunction · 0.85

Tested by

no test coverage detected