Purge goconvey and mock

These packages really impact on test readability with crazy action at a
distance. In addition to this removal of goconvey reduced the test run
time for leveldb on average by about 40-50%.
This commit is contained in:
kortschak 2014-07-05 20:43:49 +09:30
parent 3f6cfc98d5
commit 1c181429da
9 changed files with 602 additions and 587 deletions

View file

@ -21,13 +21,17 @@ import (
) )
func TestLinksTo(t *testing.T) { func TestLinksTo(t *testing.T) {
ts := new(TestTripleStore) ts := &store{
tsFixed := newFixed() data: []string{1: "cool"},
tsFixed.Add(2) iter: newFixed(),
ts.On("ValueOf", "cool").Return(1) }
ts.On("TripleIterator", graph.Object, 1).Return(tsFixed) ts.iter.(*Fixed).Add(2)
fixed := newFixed() fixed := newFixed()
fixed.Add(ts.ValueOf("cool")) val := ts.ValueOf("cool")
if val != 1 {
t.Fatalf("Failed to return correct value, got:%v expect:1", val)
}
fixed.Add(val)
lto := NewLinksTo(ts, fixed, graph.Object) lto := NewLinksTo(ts, fixed, graph.Object)
val, ok := lto.Next() val, ok := lto.Next()
if !ok { if !ok {

View file

@ -17,44 +17,58 @@ package iterator
// A quickly mocked version of the TripleStore interface, for use in tests. // A quickly mocked version of the TripleStore interface, for use in tests.
// Can better used Mock.Called but will fill in as needed. // Can better used Mock.Called but will fill in as needed.
import ( import "github.com/google/cayley/graph"
"github.com/stretchrcom/testify/mock"
"github.com/google/cayley/graph" type store struct {
) data []string
iter graph.Iterator
type TestTripleStore struct {
mock.Mock
} }
func (ts *TestTripleStore) ValueOf(s string) graph.Value { func (ts *store) ValueOf(s string) graph.Value {
args := ts.Mock.Called(s) for i, v := range ts.data {
return args.Get(0) if s == v {
return i
}
}
return nil
} }
func (ts *TestTripleStore) AddTriple(*graph.Triple) {}
func (ts *TestTripleStore) AddTripleSet([]*graph.Triple) {} func (ts *store) AddTriple(*graph.Triple) {}
func (ts *TestTripleStore) Triple(graph.Value) *graph.Triple { return &graph.Triple{} }
func (ts *TestTripleStore) TripleIterator(d graph.Direction, i graph.Value) graph.Iterator { func (ts *store) AddTripleSet([]*graph.Triple) {}
args := ts.Mock.Called(d, i)
return args.Get(0).(graph.Iterator) func (ts *store) Triple(graph.Value) *graph.Triple { return &graph.Triple{} }
func (ts *store) TripleIterator(d graph.Direction, i graph.Value) graph.Iterator {
return ts.iter
} }
func (ts *TestTripleStore) NodesAllIterator() graph.Iterator { return &Null{} }
func (ts *TestTripleStore) TriplesAllIterator() graph.Iterator { return &Null{} } func (ts *store) NodesAllIterator() graph.Iterator { return &Null{} }
func (ts *TestTripleStore) GetIteratorByString(string, string, string) graph.Iterator {
return &Null{} func (ts *store) TriplesAllIterator() graph.Iterator { return &Null{} }
func (ts *store) NameOf(v graph.Value) string {
i := v.(int)
if i < 0 || i >= len(ts.data) {
return ""
}
return ts.data[i]
} }
func (ts *TestTripleStore) NameOf(v graph.Value) string {
args := ts.Mock.Called(v) func (ts *store) Size() int64 { return 0 }
return args.Get(0).(string)
} func (ts *store) DebugPrint() {}
func (ts *TestTripleStore) Size() int64 { return 0 }
func (ts *TestTripleStore) DebugPrint() {} func (ts *store) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
func (ts *TestTripleStore) OptimizeIterator(it graph.Iterator) (graph.Iterator, bool) {
return &Null{}, false return &Null{}, false
} }
func (ts *TestTripleStore) FixedIterator() graph.FixedIterator {
func (ts *store) FixedIterator() graph.FixedIterator {
return NewFixedIteratorWithCompare(BasicEquality) return NewFixedIteratorWithCompare(BasicEquality)
} }
func (ts *TestTripleStore) Close() {}
func (ts *TestTripleStore) TripleDirection(graph.Value, graph.Direction) graph.Value { return 0 } func (ts *store) Close() {}
func (ts *TestTripleStore) RemoveTriple(t *graph.Triple) {}
func (ts *store) TripleDirection(graph.Value, graph.Direction) graph.Value { return 0 }
func (ts *store) RemoveTriple(t *graph.Triple) {}

View file

@ -15,131 +15,140 @@
package iterator package iterator
import ( import (
"reflect"
"testing" "testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/google/cayley/graph" "github.com/google/cayley/graph"
) )
func extractNumbersFromIterator(it graph.Iterator) []int { func iterated(it graph.Iterator) []int {
var outputNumbers []int var res []int
for { for {
val, ok := it.Next() val, ok := it.Next()
if !ok { if !ok {
break break
} }
outputNumbers = append(outputNumbers, val.(int)) res = append(res, val.(int))
} }
return outputNumbers return res
} }
func TestOrIteratorBasics(t *testing.T) { func TestOrIteratorBasics(t *testing.T) {
var orIt *Or or := NewOr()
f1 := newFixed()
f1.Add(1)
f1.Add(2)
f1.Add(3)
f2 := newFixed()
f2.Add(3)
f2.Add(9)
f2.Add(20)
f2.Add(21)
or.AddSubIterator(f1)
or.AddSubIterator(f2)
Convey("Given an Or Iterator of two fixed iterators", t, func() { if v, _ := or.Size(); v != 7 {
orIt = NewOr() t.Errorf("Unexpected iterator size, got:%d expected %d", v, 7)
fixed1 := newFixed() }
fixed1.Add(1)
fixed1.Add(2)
fixed1.Add(3)
fixed2 := newFixed()
fixed2.Add(3)
fixed2.Add(9)
fixed2.Add(20)
fixed2.Add(21)
orIt.AddSubIterator(fixed1)
orIt.AddSubIterator(fixed2)
Convey("It should guess its size.", func() { expect := []int{1, 2, 3, 3, 9, 20, 21}
v, _ := orIt.Size() for i := 0; i < 2; i++ {
So(v, ShouldEqual, 7) if got := iterated(or); !reflect.DeepEqual(got, expect) {
}) t.Errorf("Failed to iterate Or correctly on repeat %d, got:%v expect:%v", i, got, expect)
}
or.Reset()
}
Convey("It should extract all the numbers, potentially twice.", func() { // Check that optimization works.
allNumbers := []int{1, 2, 3, 3, 9, 20, 21} optOr, _ := or.Optimize()
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) if got := iterated(optOr); !reflect.DeepEqual(got, expect) {
orIt.Reset() t.Errorf("Failed to iterate optimized Or correctly, got:%v expect:%v", got, expect)
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) }
// Optimization works
newOr, _ := orIt.Optimize()
So(extractNumbersFromIterator(newOr), ShouldResemble, allNumbers)
})
Convey("It should check that numbers in either iterator exist.", func() { for _, v := range []int{2, 3, 21} {
So(orIt.Check(2), ShouldEqual, true) if !or.Check(v) {
So(orIt.Check(3), ShouldEqual, true) t.Errorf("Failed to correctly check %d as true", v)
So(orIt.Check(21), ShouldEqual, true) }
}) }
Convey("It should check that numbers not in either iterator are false.", func() {
So(orIt.Check(22), ShouldEqual, false)
So(orIt.Check(5), ShouldEqual, false)
So(orIt.Check(0), ShouldEqual, false)
})
})
for _, v := range []int{22, 5, 0} {
if or.Check(v) {
t.Errorf("Failed to correctly check %d as false", v)
}
}
} }
func TestShortCircuitingOrBasics(t *testing.T) { func TestShortCircuitingOrBasics(t *testing.T) {
var orIt *Or var or *Or
Convey("Given a short-circuiting Or of two fixed iterators", t, func() { f1 := newFixed()
orIt = NewShortCircuitOr() f1.Add(1)
fixed1 := newFixed() f1.Add(2)
fixed1.Add(1) f1.Add(3)
fixed1.Add(2) f2 := newFixed()
fixed1.Add(3) f2.Add(3)
fixed2 := newFixed() f2.Add(9)
fixed2.Add(3) f2.Add(20)
fixed2.Add(9) f2.Add(21)
fixed2.Add(20)
fixed2.Add(21)
Convey("It should guess its size.", func() { or = NewShortCircuitOr()
orIt.AddSubIterator(fixed1) or.AddSubIterator(f1)
orIt.AddSubIterator(fixed2) or.AddSubIterator(f2)
v, _ := orIt.Size() v, exact := or.Size()
So(v, ShouldEqual, 4) if v != 4 {
}) t.Errorf("Unexpected iterator size, got:%d expected %d", v, 4)
}
if !exact {
t.Error("Size not exact.")
}
Convey("It should extract the first iterators' numbers.", func() { // It should extract the first iterators' numbers.
orIt.AddSubIterator(fixed1) or = NewShortCircuitOr()
orIt.AddSubIterator(fixed2) or.AddSubIterator(f1)
allNumbers := []int{1, 2, 3} or.AddSubIterator(f2)
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) expect := []int{1, 2, 3}
orIt.Reset() for i := 0; i < 2; i++ {
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) if got := iterated(or); !reflect.DeepEqual(got, expect) {
// Optimization works t.Errorf("Failed to iterate Or correctly on repeat %d, got:%v expect:%v", i, got, expect)
newOr, _ := orIt.Optimize() }
So(extractNumbersFromIterator(newOr), ShouldResemble, allNumbers) or.Reset()
}) }
Convey("It should check that numbers in either iterator exist.", func() { // Check optimization works.
orIt.AddSubIterator(fixed1) optOr, _ := or.Optimize()
orIt.AddSubIterator(fixed2) if got := iterated(optOr); !reflect.DeepEqual(got, expect) {
So(orIt.Check(2), ShouldEqual, true) t.Errorf("Failed to iterate optimized Or correctly, got:%v expect:%v", got, expect)
So(orIt.Check(3), ShouldEqual, true) }
So(orIt.Check(21), ShouldEqual, true)
So(orIt.Check(22), ShouldEqual, false)
So(orIt.Check(5), ShouldEqual, false)
So(orIt.Check(0), ShouldEqual, false)
}) // Check that numbers in either iterator exist.
or = NewShortCircuitOr()
Convey("It should check that it pulls the second iterator's numbers if the first is empty.", func() { or.AddSubIterator(f1)
orIt.AddSubIterator(newFixed()) or.AddSubIterator(f2)
orIt.AddSubIterator(fixed2) for _, v := range []int{2, 3, 21} {
allNumbers := []int{3, 9, 20, 21} if !or.Check(v) {
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) t.Errorf("Failed to correctly check %d as true", v)
orIt.Reset() }
So(extractNumbersFromIterator(orIt), ShouldResemble, allNumbers) }
// Optimization works for _, v := range []int{22, 5, 0} {
newOr, _ := orIt.Optimize() if or.Check(v) {
So(extractNumbersFromIterator(newOr), ShouldResemble, allNumbers) t.Errorf("Failed to correctly check %d as false", v)
}) }
}
})
// Check that it pulls the second iterator's numbers if the first is empty.
or = NewShortCircuitOr()
or.AddSubIterator(newFixed())
or.AddSubIterator(f2)
expect = []int{3, 9, 20, 21}
for i := 0; i < 2; i++ {
if got := iterated(or); !reflect.DeepEqual(got, expect) {
t.Errorf("Failed to iterate Or correctly on repeat %d, got:%v expect:%v", i, got, expect)
}
or.Reset()
}
// Check optimization works.
optOr, _ = or.Optimize()
if got := iterated(optOr); !reflect.DeepEqual(got, expect) {
t.Errorf("Failed to iterate optimized Or correctly, got:%v expect:%v", got, expect)
}
} }

View file

@ -42,7 +42,7 @@ type queryShape struct {
hasaDirs []graph.Direction hasaDirs []graph.Direction
} }
func OutputQueryShapeForIterator(it graph.Iterator, ts graph.TripleStore, outputMap *map[string]interface{}) { func OutputQueryShapeForIterator(it graph.Iterator, ts graph.TripleStore, outputMap map[string]interface{}) {
qs := &queryShape{ qs := &queryShape{
ts: ts, ts: ts,
nodeId: 1, nodeId: 1,
@ -50,8 +50,8 @@ func OutputQueryShapeForIterator(it graph.Iterator, ts graph.TripleStore, output
node := qs.MakeNode(it.Clone()) node := qs.MakeNode(it.Clone())
qs.AddNode(node) qs.AddNode(node)
(*outputMap)["nodes"] = qs.nodes outputMap["nodes"] = qs.nodes
(*outputMap)["links"] = qs.links outputMap["links"] = qs.links
} }
func (qs *queryShape) AddNode(n *Node) { func (qs *queryShape) AddNode(n *Node) {

View file

@ -15,112 +15,116 @@
package iterator package iterator
import ( import (
"reflect"
"testing" "testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/google/cayley/graph" "github.com/google/cayley/graph"
) )
func buildHasaWithTag(ts graph.TripleStore, tag string, target string) *HasA { func hasaWithTag(ts graph.TripleStore, tag string, target string) *HasA {
fixed_obj := ts.FixedIterator()
fixed_pred := ts.FixedIterator()
fixed_obj.Add(ts.ValueOf(target))
fixed_pred.Add(ts.ValueOf("status"))
fixed_obj.AddTag(tag)
lto1 := NewLinksTo(ts, fixed_obj, graph.Object)
lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate)
and := NewAnd() and := NewAnd()
and.AddSubIterator(lto1)
and.AddSubIterator(lto2) obj := ts.FixedIterator()
hasa := NewHasA(ts, and, graph.Subject) obj.Add(ts.ValueOf(target))
return hasa obj.AddTag(tag)
and.AddSubIterator(NewLinksTo(ts, obj, graph.Object))
pred := ts.FixedIterator()
pred.Add(ts.ValueOf("status"))
and.AddSubIterator(NewLinksTo(ts, pred, graph.Predicate))
return NewHasA(ts, and, graph.Subject)
} }
func TestQueryShape(t *testing.T) { func TestQueryShape(t *testing.T) {
var queryShape map[string]interface{} ts := &store{
ts := new(TestTripleStore) data: []string{
ts.On("ValueOf", "cool").Return(1) 1: "cool",
ts.On("NameOf", 1).Return("cool") 2: "status",
ts.On("ValueOf", "status").Return(2) 3: "fun",
ts.On("NameOf", 2).Return("status") 4: "name",
ts.On("ValueOf", "fun").Return(3) },
ts.On("NameOf", 3).Return("fun") }
ts.On("ValueOf", "name").Return(4)
ts.On("NameOf", 4).Return("name")
Convey("Given a single linkage iterator's shape", t, func() { // Given a single linkage iterator's shape.
queryShape = make(map[string]interface{}) hasa := hasaWithTag(ts, "tag", "cool")
hasa := buildHasaWithTag(ts, "tag", "cool") hasa.AddTag("top")
hasa.AddTag("top")
OutputQueryShapeForIterator(hasa, ts, &queryShape)
Convey("It should have three nodes and one link", func() { shape := make(map[string]interface{})
nodes := queryShape["nodes"].([]Node) OutputQueryShapeForIterator(hasa, ts, shape)
links := queryShape["links"].([]Link)
So(len(nodes), ShouldEqual, 3)
So(len(links), ShouldEqual, 1)
})
Convey("These nodes should be correctly tagged", func() { nodes := shape["nodes"].([]Node)
nodes := queryShape["nodes"].([]Node) if len(nodes) != 3 {
So(nodes[0].Tags, ShouldResemble, []string{"tag"}) t.Errorf("Failed to get correct number of nodes, got:%d expect:4", len(nodes))
So(nodes[1].IsLinkNode, ShouldEqual, true) }
So(nodes[2].Tags, ShouldResemble, []string{"top"}) links := shape["links"].([]Link)
if len(nodes) != 3 {
t.Errorf("Failed to get correct number of links, got:%d expect:1", len(links))
}
}) // Nodes should be correctly tagged.
nodes = shape["nodes"].([]Node)
for i, expect := range [][]string{{"tag"}, nil, {"top"}} {
if !reflect.DeepEqual(nodes[i].Tags, expect) {
t.Errorf("Failed to get correct tag for node[%d], got:%s expect:%s", i, nodes[i].Tags, expect)
}
}
if !nodes[1].IsLinkNode {
t.Error("Failed to get node[1] as link node")
}
Convey("The link should be correctly typed", func() { // Link should be correctly typed.
nodes := queryShape["nodes"].([]Node) nodes = shape["nodes"].([]Node)
links := queryShape["links"].([]Link) link := shape["links"].([]Link)[0]
So(links[0].Source, ShouldEqual, nodes[2].Id) if link.Source != nodes[2].Id {
So(links[0].Target, ShouldEqual, nodes[0].Id) t.Errorf("Failed to get correct link source, got:%v expect:%v", link.Source, nodes[2].Id)
So(links[0].LinkNode, ShouldEqual, nodes[1].Id) }
So(links[0].Pred, ShouldEqual, 0) if link.Target != nodes[0].Id {
t.Errorf("Failed to get correct link target, got:%v expect:%v", link.Target, nodes[0].Id)
}
if link.LinkNode != nodes[1].Id {
t.Errorf("Failed to get correct link node, got:%v expect:%v", link.LinkNode, nodes[1].Id)
}
if link.Pred != 0 {
t.Errorf("Failed to get correct number of predecessors:%v expect:0", link.Pred)
}
}) // Given a name-of-an-and-iterator's shape.
andInternal := NewAnd()
}) hasa1 := hasaWithTag(ts, "tag1", "cool")
hasa1.AddTag("hasa1")
andInternal.AddSubIterator(hasa1)
Convey("Given a name-of-an-and-iterator's shape", t, func() { hasa2 := hasaWithTag(ts, "tag2", "fun")
queryShape = make(map[string]interface{}) hasa2.AddTag("hasa2")
hasa1 := buildHasaWithTag(ts, "tag1", "cool") andInternal.AddSubIterator(hasa2)
hasa1.AddTag("hasa1")
hasa2 := buildHasaWithTag(ts, "tag2", "fun")
hasa1.AddTag("hasa2")
andInternal := NewAnd()
andInternal.AddSubIterator(hasa1)
andInternal.AddSubIterator(hasa2)
fixed_pred := ts.FixedIterator()
fixed_pred.Add(ts.ValueOf("name"))
lto1 := NewLinksTo(ts, andInternal, graph.Subject)
lto2 := NewLinksTo(ts, fixed_pred, graph.Predicate)
and := NewAnd()
and.AddSubIterator(lto1)
and.AddSubIterator(lto2)
hasa := NewHasA(ts, and, graph.Object)
OutputQueryShapeForIterator(hasa, ts, &queryShape)
Convey("It should have seven nodes and three links", func() { pred := ts.FixedIterator()
nodes := queryShape["nodes"].([]Node) pred.Add(ts.ValueOf("name"))
links := queryShape["links"].([]Link)
So(len(nodes), ShouldEqual, 7)
So(len(links), ShouldEqual, 3)
})
Convey("Three of the nodes are link nodes, four aren't", func() { and := NewAnd()
nodes := queryShape["nodes"].([]Node) and.AddSubIterator(NewLinksTo(ts, andInternal, graph.Subject))
count := 0 and.AddSubIterator(NewLinksTo(ts, pred, graph.Predicate))
for _, node := range nodes {
if node.IsLinkNode {
count++
}
}
So(count, ShouldEqual, 3)
})
Convey("These nodes should be correctly tagged", nil) shape = make(map[string]interface{})
OutputQueryShapeForIterator(NewHasA(ts, and, graph.Object), ts, shape)
})
links = shape["links"].([]Link)
if len(links) != 3 {
t.Errorf("Failed to find the correct number of links, got:%d expect:3", len(links))
}
nodes = shape["nodes"].([]Node)
if len(nodes) != 7 {
t.Errorf("Failed to find the correct number of nodes, got:%d expect:7", len(nodes))
}
var n int
for _, node := range nodes {
if node.IsLinkNode {
n++
}
}
if n != 3 {
t.Errorf("Failed to find the correct number of link nodes, got:%d expect:3", n)
}
} }

View file

@ -20,35 +20,14 @@ import (
"github.com/google/cayley/graph" "github.com/google/cayley/graph"
) )
func SetupMockTripleStore(nameMap map[string]int) *TestTripleStore { var simpleStore = &store{data: []string{"0", "1", "2", "3", "4", "5"}}
ts := new(TestTripleStore)
for k, v := range nameMap { func simpleFixedIterator() *Fixed {
ts.On("ValueOf", k).Return(v) f := newFixed()
ts.On("NameOf", v).Return(k) for i := 0; i < 5; i++ {
f.Add(i)
} }
return ts return f
}
func SimpleValueTripleStore() *TestTripleStore {
ts := SetupMockTripleStore(map[string]int{
"0": 0,
"1": 1,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
})
return ts
}
func BuildFixedIterator() *Fixed {
fixed := newFixed()
fixed.Add(0)
fixed.Add(1)
fixed.Add(2)
fixed.Add(3)
fixed.Add(4)
return fixed
} }
func checkIteratorContains(ts graph.TripleStore, it graph.Iterator, expected []string, t *testing.T) { func checkIteratorContains(ts graph.TripleStore, it graph.Iterator, expected []string, t *testing.T) {
@ -82,36 +61,36 @@ func checkIteratorContains(ts graph.TripleStore, it graph.Iterator, expected []s
} }
func TestWorkingIntValueComparison(t *testing.T) { func TestWorkingIntValueComparison(t *testing.T) {
ts := SimpleValueTripleStore() ts := simpleStore
fixed := BuildFixedIterator() fixed := simpleFixedIterator()
vc := NewComparison(fixed, kCompareLT, int64(3), ts) vc := NewComparison(fixed, kCompareLT, int64(3), ts)
checkIteratorContains(ts, vc, []string{"0", "1", "2"}, t) checkIteratorContains(ts, vc, []string{"0", "1", "2"}, t)
} }
func TestFailingIntValueComparison(t *testing.T) { func TestFailingIntValueComparison(t *testing.T) {
ts := SimpleValueTripleStore() ts := simpleStore
fixed := BuildFixedIterator() fixed := simpleFixedIterator()
vc := NewComparison(fixed, kCompareLT, int64(0), ts) vc := NewComparison(fixed, kCompareLT, int64(0), ts)
checkIteratorContains(ts, vc, []string{}, t) checkIteratorContains(ts, vc, []string{}, t)
} }
func TestWorkingGT(t *testing.T) { func TestWorkingGT(t *testing.T) {
ts := SimpleValueTripleStore() ts := simpleStore
fixed := BuildFixedIterator() fixed := simpleFixedIterator()
vc := NewComparison(fixed, kCompareGT, int64(2), ts) vc := NewComparison(fixed, kCompareGT, int64(2), ts)
checkIteratorContains(ts, vc, []string{"3", "4"}, t) checkIteratorContains(ts, vc, []string{"3", "4"}, t)
} }
func TestWorkingGTE(t *testing.T) { func TestWorkingGTE(t *testing.T) {
ts := SimpleValueTripleStore() ts := simpleStore
fixed := BuildFixedIterator() fixed := simpleFixedIterator()
vc := NewComparison(fixed, kCompareGTE, int64(2), ts) vc := NewComparison(fixed, kCompareGTE, int64(2), ts)
checkIteratorContains(ts, vc, []string{"2", "3", "4"}, t) checkIteratorContains(ts, vc, []string{"2", "3", "4"}, t)
} }
func TestVCICheck(t *testing.T) { func TestVCICheck(t *testing.T) {
ts := SimpleValueTripleStore() ts := simpleStore
fixed := BuildFixedIterator() fixed := simpleFixedIterator()
vc := NewComparison(fixed, kCompareGTE, int64(2), ts) vc := NewComparison(fixed, kCompareGTE, int64(2), ts)
if vc.Check(1) { if vc.Check(1) {
t.Error("1 is less than 2, should be GTE") t.Error("1 is less than 2, should be GTE")

File diff suppressed because it is too large Load diff

View file

@ -239,7 +239,7 @@ func runIteratorWithCallback(it graph.Iterator, ses *Session, callback otto.Valu
func runIteratorOnSession(it graph.Iterator, ses *Session) { func runIteratorOnSession(it graph.Iterator, ses *Session) {
if ses.lookingForQueryShape { if ses.lookingForQueryShape {
iterator.OutputQueryShapeForIterator(it, ses.ts, &(ses.queryShape)) iterator.OutputQueryShapeForIterator(it, ses.ts, ses.queryShape)
return return
} }
it, _ = it.Optimize() it, _ = it.Optimize()

View file

@ -51,7 +51,7 @@ func (m *Session) GetQuery(input string, output_struct chan map[string]interface
m.currentQuery = NewQuery(m) m.currentQuery = NewQuery(m)
m.currentQuery.BuildIteratorTree(mqlQuery) m.currentQuery.BuildIteratorTree(mqlQuery)
output := make(map[string]interface{}) output := make(map[string]interface{})
iterator.OutputQueryShapeForIterator(m.currentQuery.it, m.ts, &output) iterator.OutputQueryShapeForIterator(m.currentQuery.it, m.ts, output)
nodes := output["nodes"].([]iterator.Node) nodes := output["nodes"].([]iterator.Node)
new_nodes := make([]iterator.Node, 0) new_nodes := make([]iterator.Node, 0)
for _, n := range nodes { for _, n := range nodes {