mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 08:51:02 -06:00
dag: Update can be called with a nil graph
This commit is contained in:
parent
65752cd51a
commit
6366488809
@ -136,7 +136,10 @@ func (w *Walker) Wait() error {
|
||||
// Multiple Updates can be called in parallel. Update can be called at any
|
||||
// time during a walk.
|
||||
func (w *Walker) Update(g *Graph) {
|
||||
v, e := g.vertices, g.edges
|
||||
var v, e *Set
|
||||
if g != nil {
|
||||
v, e = g.vertices, g.edges
|
||||
}
|
||||
|
||||
// Grab the change lock so no more updates happen but also so that
|
||||
// no new vertices are executed during this time since we may be
|
||||
|
@ -33,6 +33,26 @@ func TestWalker_basic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWalker_updateNilGraph(t *testing.T) {
|
||||
var g Graph
|
||||
g.Add(1)
|
||||
g.Add(2)
|
||||
g.Connect(BasicEdge(1, 2))
|
||||
|
||||
// Run it a bunch of times since it is timing dependent
|
||||
for i := 0; i < 50; i++ {
|
||||
var order []interface{}
|
||||
w := &Walker{Callback: walkCbRecord(&order)}
|
||||
w.Update(&g)
|
||||
w.Update(nil)
|
||||
|
||||
// Wait
|
||||
if err := w.Wait(); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWalker_error(t *testing.T) {
|
||||
var g Graph
|
||||
g.Add(1)
|
||||
|
Loading…
Reference in New Issue
Block a user