MCPcopy
hub / github.com/larksuite/cli / TestBuilder_basicAssembly

Function TestBuilder_basicAssembly

extension/platform/builder_test.go:63–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestBuilder_basicAssembly(t *testing.T) {
64 p, err := platform.NewPlugin("audit", "0.1.0").
65 Observer(platform.Before, "pre", platform.All(),
66 func(context.Context, platform.Invocation) {}).
67 Observer(platform.After, "post", platform.All(),
68 func(context.Context, platform.Invocation) {}).
69 Wrap("policy", platform.All(),
70 func(next platform.Handler) platform.Handler { return next }).
71 On(platform.Startup, "boot",
72 func(context.Context, *platform.LifecycleContext) error { return nil }).
73 FailOpen().
74 Build()
75 if err != nil {
76 t.Fatalf("Build: %v", err)
77 }
78 if p.Name() != "audit" || p.Version() != "0.1.0" {
79 t.Errorf("metadata = %q/%q", p.Name(), p.Version())
80 }
81 if p.Capabilities().FailurePolicy != platform.FailOpen {
82 t.Errorf("FailurePolicy = %v, want FailOpen", p.Capabilities().FailurePolicy)
83 }
84
85 r := &recorder{}
86 if err := p.Install(r); err != nil {
87 t.Fatalf("Install: %v", err)
88 }
89 if r.observers != 2 || r.wrappers != 1 || r.lifecycles != 1 {
90 t.Errorf("Install dispatch = observers=%d wrappers=%d lifecycles=%d",
91 r.observers, r.wrappers, r.lifecycles)
92 }
93}
94
95// Restrict() flips Restricts=true and FailClosed automatically — a
96// policy plugin can't accidentally ship under FailOpen.

Callers

nothing calls this directly

Calls 11

NewPluginFunction · 0.92
AllFunction · 0.92
FailOpenMethod · 0.80
ObserverMethod · 0.80
BuildMethod · 0.65
OnMethod · 0.65
WrapMethod · 0.65
NameMethod · 0.65
VersionMethod · 0.65
CapabilitiesMethod · 0.65
InstallMethod · 0.65

Tested by

no test coverage detected