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

Function TestTransactionForCost

dgraph/cmd/alpha/http_test.go:491–523  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

489 require.Equal(t, `{"data":{"balances":[{"name":"Bob","balance":"110"}]}}`, data)
490}
491func TestTransactionForCost(t *testing.T) {
492 require.NoError(t, dropAll())
493 require.NoError(t, alterSchema(`name: string @index(term) .`))
494
495 q1 := `
496 {
497 balances(func: anyofterms(name, "Alice Bob")) {
498 name
499 balance
500 }
501 }
502 `
503 _, _, err := queryWithTs(queryInp{body: q1, typ: "application/dql"})
504 require.NoError(t, err)
505
506 m1 := `
507 {
508 set {
509 _:alice <name> "Bob" .
510 _:alice <balance> "110" .
511 _:bob <balance> "60" .
512 }
513 }
514 `
515
516 mr, err := mutationWithTs(mutationInp{body: m1, typ: "application/rdf", commitNow: true})
517 require.NoError(t, err)
518 require.Equal(t, "5", mr.cost)
519
520 _, _, resp, err := queryWithTsForResp(queryInp{body: q1, typ: "application/dql"})
521 require.NoError(t, err)
522 require.Equal(t, "2", resp.Header.Get(x.DgraphCostHeader))
523}
524
525func TestTransactionBasicOldCommitFormat(t *testing.T) {
526 require.NoError(t, dropAll())

Callers

nothing calls this directly

Calls 6

dropAllFunction · 0.85
alterSchemaFunction · 0.85
queryWithTsFunction · 0.85
mutationWithTsFunction · 0.85
queryWithTsForRespFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…