Files
zeekayandHanzo Dev 16323edc61 A router named by an alias is still the router
A host that re-exports the type writes `type Router = *zip.App` and hands a
Router to every plugin. That is the same type, but it arrives as
types.Alias, so matching the shape directly saw neither an App nor a Group
and the op's prefix could not be resolved — which refuses the whole
document rather than filing one path wrongly. Unalias at each place a type
is matched by shape, including the In and Out inferred from a handler.

A group is also read when var names it, not only :=. The prefix belongs to
the Group call; the syntax that binds the result does not change it.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 20:34:07 -07:00

27 lines
838 B
Go

package zipdoc
import "testing"
// A host may name the router type with an alias and hand that to every plugin.
// An alias is the same type, so an op registered on one is registered on the
// app — the extractor has to see through the name to the shape. The last op
// also fixes the spelling that names a group with var rather than :=, which
// is the same call either way.
func TestExtract_ARouterNamedByAnAliasIsStillTheApp(t *testing.T) {
p := load(t, "alias")
for _, want := range []string{"POST /v1/ask", "POST /v1/ask/history/replay", "POST /v1/ask/audit/entries"} {
op := opByKey(t, p, want)
if op.Description == "" {
t.Errorf("%s has no prose", want)
}
}
if len(p.Ops) != 3 {
var k []string
for _, o := range p.Ops {
k = append(k, o.Key())
}
t.Fatalf("ops = %d, want 3; got %v", len(p.Ops), k)
}
}