From a5b3b7acd0669efd9a30c6894274b18ce9c52e3f Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 4 Oct 2018 15:02:12 -0400 Subject: [PATCH] graph: fix TestVisitBreadth test to ensure edge is to a brand new value during a newRank action --- graph/graph_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/graph/graph_test.go b/graph/graph_test.go index 2f89ec4..578fc80 100644 --- a/graph/graph_test.go +++ b/graph/graph_test.go @@ -286,6 +286,15 @@ func TestVisitBreadth(t *T) { return strV(mrand.Element(rankL, nil).(string)) } + randNew := func(s state) Value { + for { + v := strV(mrand.Hex(2)) + if !s.g.Has(v) { + return v + } + } + } + type params struct { newRank bool e Edge @@ -305,7 +314,7 @@ func TestVisitBreadth(t *T) { var p params p.newRank = len(thisRank(s)) > 0 && mrand.Intn(10) == 0 if p.newRank { - p.e.Head = strV(mrand.Hex(3)) + p.e.Head = randNew(s) p.e.Tail = randFromRank(s, thisRank) } else { p.e.Head = strV(mrand.Hex(2))