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

Function setup

dgraph/cmd/increment/increment_test.go:126–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func setup(t *testing.T) *dgo.Dgraph {
127 dg, err := testutil.DgraphClientWithGroot(testutil.GetSockAddr())
128 if err != nil {
129 t.Fatalf("Error while getting a dgraph client: %v", err)
130 }
131 ctx := context.Background()
132 op := api.Operation{DropAll: true}
133
134 // The following piece of code shows how one can set metadata with
135 // auth-token, to allow Alter operation, if the server requires it.
136 md := metadata.New(nil)
137 md.Append("auth-token", "mrjn2")
138 ctx = metadata.NewOutgoingContext(ctx, md)
139 if err := dg.Alter(ctx, &op); err != nil {
140 t.Fatalf("Cannot perform drop all op: %s", err.Error())
141 }
142
143 conf := viper.New()
144 conf.Set("pred", "counter.val")
145 cnt, err := process(dg, conf)
146 if err != nil {
147 t.Logf("Error while reading: %v\n", err)
148 } else {
149 t.Logf("Initial value: %d\n", cnt.Val)
150 }
151
152 return dg
153}
154
155func TestIncrement(t *testing.T) {
156 dg := setup(t)

Callers 4

TestIncrementFunction · 0.70
TestBestEffortFunction · 0.70
TestBestEffortOnlyFunction · 0.70
TestBestEffortTsFunction · 0.70

Calls 7

DgraphClientWithGrootFunction · 0.92
GetSockAddrFunction · 0.92
processFunction · 0.85
FatalfMethod · 0.80
AlterMethod · 0.80
SetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected