engine: graph, resources: Add filtered graph function

This lets a resource query the resource graph in a controlled way.
This commit is contained in:
James Shubin
2019-10-25 09:36:27 -04:00
parent 31030343a2
commit eaab1aae28
3 changed files with 67 additions and 0 deletions

View File

@@ -603,6 +603,19 @@ func TestResources2(t *testing.T) {
Recv: func() map[string]*engine.Send {
return map[string]*engine.Send{}
},
// Copied from state.go
FilteredGraph: func() (*pgraph.Graph, error) {
graph, err := pgraph.NewGraph("filtered")
if err != nil {
return nil, errwrap.Wrapf(err, "could not create graph")
}
// Hack: We just add ourself as allowed since
// we're just a one-vertex test suite...
graph.AddVertex(res) // hack!
return graph, nil // we return in a func so it's fresh!
},
}
// run Init
return func() error {