(t *testing.T)
| 623 | } |
| 624 | |
| 625 | func TestParseWithNamespace(t *testing.T) { |
| 626 | reset() |
| 627 | result, err := Parse(` |
| 628 | [10] jobs: [string] @index(term) . |
| 629 | [0x123] occupations: [string] . |
| 630 | [0xf2] graduation: [dateTime] . |
| 631 | [0xf2] type Person { |
| 632 | name: [string!]! |
| 633 | address: string! |
| 634 | children: [Person] |
| 635 | } |
| 636 | `) |
| 637 | require.NoError(t, err) |
| 638 | require.Equal(t, 3, len(result.Preds)) |
| 639 | require.EqualValues(t, &pb.SchemaUpdate{ |
| 640 | Predicate: x.NamespaceAttr(10, "jobs"), |
| 641 | ValueType: 9, |
| 642 | Directive: pb.SchemaUpdate_INDEX, |
| 643 | Tokenizer: []string{"term"}, |
| 644 | List: true, |
| 645 | }, result.Preds[0]) |
| 646 | |
| 647 | require.EqualValues(t, &pb.SchemaUpdate{ |
| 648 | Predicate: x.NamespaceAttr(0x123, "occupations"), |
| 649 | ValueType: 9, |
| 650 | List: true, |
| 651 | }, result.Preds[1]) |
| 652 | |
| 653 | require.EqualValues(t, &pb.SchemaUpdate{ |
| 654 | Predicate: x.NamespaceAttr(0xf2, "graduation"), |
| 655 | ValueType: 5, |
| 656 | List: true, |
| 657 | }, result.Preds[2]) |
| 658 | |
| 659 | require.NoError(t, err) |
| 660 | require.Equal(t, 1, len(result.Types)) |
| 661 | require.Equal(t, &pb.TypeUpdate{ |
| 662 | TypeName: x.NamespaceAttr(0xf2, "Person"), |
| 663 | Fields: []*pb.SchemaUpdate{ |
| 664 | { |
| 665 | Predicate: x.NamespaceAttr(0xf2, "name"), |
| 666 | }, |
| 667 | { |
| 668 | Predicate: x.NamespaceAttr(0xf2, "address"), |
| 669 | }, |
| 670 | { |
| 671 | Predicate: x.NamespaceAttr(0xf2, "children"), |
| 672 | }, |
| 673 | }, |
| 674 | }, result.Types[0]) |
| 675 | } |
| 676 | |
| 677 | var ps *badger.DB |
| 678 |
nothing calls this directly
no test coverage detected