(t *testing.T)
| 357 | } |
| 358 | |
| 359 | func TestNoConflictQuery2(t *testing.T) { |
| 360 | schema := ` |
| 361 | type node { |
| 362 | name_noconflict: string |
| 363 | address_conflict: string |
| 364 | child: uid |
| 365 | } |
| 366 | |
| 367 | name_noconflict: string @noconflict . |
| 368 | address_conflict: string . |
| 369 | child: uid . |
| 370 | ` |
| 371 | setSchema(schema) |
| 372 | |
| 373 | type node struct { |
| 374 | ID string `json:"uid"` |
| 375 | Name string `json:"name_noconflict"` |
| 376 | Child *node `json:"child"` |
| 377 | Address string `json:"address_conflict"` |
| 378 | } |
| 379 | |
| 380 | child := node{ID: "_:blank-0", Name: "child", Address: "dgraph labs"} |
| 381 | js, err := json.Marshal(child) |
| 382 | require.NoError(t, err) |
| 383 | |
| 384 | res, err := client.NewTxn().Mutate(context.Background(), |
| 385 | &api.Mutation{SetJson: js, CommitNow: true}) |
| 386 | require.NoError(t, err) |
| 387 | |
| 388 | in := []node{} |
| 389 | for i := 0; i < 5; i++ { |
| 390 | in = append(in, node{ID: "_:blank-0", Name: fmt.Sprintf("%d", i+1), |
| 391 | Child: &node{ID: res.GetUids()["blank-0"]}}) |
| 392 | } |
| 393 | |
| 394 | errChan := make(chan error) |
| 395 | for i := range in { |
| 396 | go func(n node) { |
| 397 | js, err := json.Marshal(n) |
| 398 | require.NoError(t, err) |
| 399 | |
| 400 | _, err = client.NewTxn().Mutate(context.Background(), |
| 401 | &api.Mutation{SetJson: js, CommitNow: true}) |
| 402 | errChan <- err |
| 403 | }(in[i]) |
| 404 | } |
| 405 | |
| 406 | errs := []error{} |
| 407 | for i := 0; i < len(in); i++ { |
| 408 | errs = append(errs, <-errChan) |
| 409 | } |
| 410 | |
| 411 | hasError := false |
| 412 | for _, e := range errs { |
| 413 | if e != nil { |
| 414 | hasError = true |
| 415 | require.Contains(t, e.Error(), "Transaction has been aborted. Please retry") |
| 416 | } |
nothing calls this directly
no test coverage detected