DgraphClientWithGroot creates a Dgraph client with groot permissions set up. It is intended to be called from TestMain() to establish a Dgraph connection shared by all tests, so there is no testing.T instance for it to use.
(serviceAddr string)
| 310 | // It is intended to be called from TestMain() to establish a Dgraph connection shared |
| 311 | // by all tests, so there is no testing.T instance for it to use. |
| 312 | func DgraphClientWithGroot(serviceAddr string) (*dgo.Dgraph, error) { |
| 313 | dg, err := DgraphClient(serviceAddr) |
| 314 | if err != nil { |
| 315 | return nil, err |
| 316 | } |
| 317 | |
| 318 | ctx := context.Background() |
| 319 | for { |
| 320 | // keep retrying until we succeed or receive a non-retriable error |
| 321 | err = dg.LoginIntoNamespace(ctx, x.GrootId, "password", x.RootNamespace) |
| 322 | if err == nil || !(strings.Contains(err.Error(), "Please retry") || |
| 323 | strings.Contains(err.Error(), "user not found")) { |
| 324 | |
| 325 | break |
| 326 | } |
| 327 | time.Sleep(time.Second) |
| 328 | } |
| 329 | |
| 330 | return dg, err |
| 331 | } |
| 332 | |
| 333 | // DgraphClient creates a Dgraph client. |
| 334 | // It is intended to be called from TestMain() to establish a Dgraph connection shared |