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

Function incrementInLoop

dgraph/cmd/increment/increment_test.go:31–52  ·  view source on GitHub ↗
(t *testing.T, dg *dgo.Dgraph, M int)

Source from the content-addressed store, hash-verified

29const N = 10
30
31func incrementInLoop(t *testing.T, dg *dgo.Dgraph, M int) int {
32 conf := viper.New()
33 conf.Set("pred", "counter.val")
34
35 var max int
36 for i := 0; i < M; i++ {
37 cnt, err := process(dg, conf)
38 if err != nil {
39 if strings.Contains(err.Error(), "Transaction has been aborted") {
40 // pass
41 } else {
42 t.Logf("Error while incrementing: %v\n", err)
43 }
44 } else {
45 if cnt.Val > max {
46 max = cnt.Val
47 }
48 }
49 }
50 t.Logf("Last value written by increment in loop: %d", max)
51 return max
52}
53
54func increment(t *testing.T, dg *dgo.Dgraph) int {
55 var max int

Callers 3

incrementFunction · 0.85
TestBestEffortFunction · 0.85
TestBestEffortTsFunction · 0.85

Calls 3

processFunction · 0.85
SetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected