(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestRecursiveNextPath(t *testing.T) { |
| 91 | ctx := context.TODO() |
| 92 | qs := rec_test_qs |
| 93 | start := qs.NodesAllIterator() |
| 94 | start = Tag(start, "person") |
| 95 | it := singleHop(qs, "follows")(start) |
| 96 | and := NewAnd() |
| 97 | and.AddSubIterator(it) |
| 98 | fixed := NewFixed() |
| 99 | fixed.Add(graph.PreFetched(quad.Raw("alice"))) |
| 100 | and.AddSubIterator(fixed) |
| 101 | r := NewRecursive(and, singleHop(qs, "parent"), 0) |
| 102 | |
| 103 | expected := []string{"fred", "fred", "fred", "fred", "greg", "greg", "greg", "greg"} |
| 104 | var got []string |
| 105 | for r.Next(ctx) { |
| 106 | res := make(map[string]graph.Ref) |
| 107 | r.TagResults(res) |
| 108 | got = append(got, quad.ToString(qs.NameOf(res["person"]))) |
| 109 | for r.NextPath(ctx) { |
| 110 | res := make(map[string]graph.Ref) |
| 111 | r.TagResults(res) |
| 112 | got = append(got, quad.ToString(qs.NameOf(res["person"]))) |
| 113 | } |
| 114 | } |
| 115 | sort.Strings(expected) |
| 116 | sort.Strings(got) |
| 117 | if !reflect.DeepEqual(got, expected) { |
| 118 | t.Errorf("Failed to check NextPath, got: %v, expected: %v", got, expected) |
| 119 | } |
| 120 | } |
nothing calls this directly
no test coverage detected