mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
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]>
27 lines
838 B
Go
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)
|
|
}
|
|
}
|