MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / newBlockingRegisterHost

Function newBlockingRegisterHost

internal/pluginhost/host_test.go:1189–1220  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1187}
1188
1189func newBlockingRegisterHost(t *testing.T) (*Host, *config.Config, <-chan struct{}, func()) {
1190 t.Helper()
1191
1192 loader := newTestSymbolLoader()
1193 registerStarted := make(chan struct{})
1194 release := make(chan struct{})
1195 var startOnce sync.Once
1196 var releaseOnce sync.Once
1197 releaseRegister := func() { releaseOnce.Do(func() { close(release) }) }
1198 t.Cleanup(releaseRegister)
1199
1200 plugin := &testPlugin{
1201 registerResult: validTestPlugin("alpha"),
1202 reconfigureResult: validTestPlugin("alpha"),
1203 }
1204 lookup := newTestSymbolLookup(plugin)
1205 lookup.registerOverride = func([]byte) pluginapi.Plugin {
1206 startOnce.Do(func() { close(registerStarted) })
1207 <-release
1208 return validTestPlugin("alpha")
1209 }
1210 loader.lookups["alpha"] = lookup
1211 h := NewForTest(loader)
1212 cfg := &config.Config{
1213 Plugins: config.PluginsConfig{
1214 Enabled: true,
1215 Dir: makePluginDir(t, "alpha"),
1216 Configs: enabledPluginConfigs("alpha"),
1217 },
1218 }
1219 return h, cfg, registerStarted, releaseRegister
1220}
1221
1222func waitForHostTestSignal(t *testing.T, ch <-chan struct{}, name string) {
1223 t.Helper()

Calls 8

newTestSymbolLoaderFunction · 0.85
validTestPluginFunction · 0.85
newTestSymbolLookupFunction · 0.85
NewForTestFunction · 0.85
makePluginDirFunction · 0.85
enabledPluginConfigsFunction · 0.85
DoMethod · 0.65
CleanupMethod · 0.45

Tested by

no test coverage detected