resources: Create a common ResourceFinder interface

And make both .Resources and resources implement it.

This gets us 2 new methods/functions, so you can now also do:

* .Resources.Get
* resources.ByType

Note that GetRemote is not covered by this interface, as that is only available as a global template function.

Fixes #8653
This commit is contained in:
Bjørn Erik Pedersen
2021-10-20 10:11:48 +02:00
parent 20162518c4
commit e58a540895
7 changed files with 148 additions and 36 deletions

View File

@@ -553,7 +553,8 @@ HEADLESS {{< myShort >}}
headlessResources := headless.Resources()
c.Assert(len(headlessResources), qt.Equals, 3)
c.Assert(len(headlessResources.Match("l*")), qt.Equals, 2)
res := headlessResources.Match("l*")
c.Assert(len(res), qt.Equals, 2)
pageResource := headlessResources.GetMatch("p*")
c.Assert(pageResource, qt.Not(qt.IsNil))
p := pageResource.(page.Page)