@@ -16,6 +16,15 @@ import (
1616 "github.com/tidwall/gjson"
1717)
1818
19+ func enabledPluginConfigs (ids ... string ) map [string ]config.PluginInstanceConfig {
20+ enabled := true
21+ configs := make (map [string ]config.PluginInstanceConfig , len (ids ))
22+ for _ , id := range ids {
23+ configs [id ] = config.PluginInstanceConfig {Enabled : & enabled }
24+ }
25+ return configs
26+ }
27+
1928func TestHostApplyConfig_DisabledGlobalSkipsSnapshot (t * testing.T ) {
2029 loader := newTestSymbolLoader ()
2130 h := NewForTest (loader )
@@ -67,6 +76,30 @@ func TestHostApplyConfig_DisabledPluginSkipsCapability(t *testing.T) {
6776 }
6877}
6978
79+ func TestHostApplyConfig_DefaultDisabledPluginSkipsLoad (t * testing.T ) {
80+ loader := newTestSymbolLoader ()
81+ plugin := & testPlugin {
82+ registerResult : validTestPlugin ("alpha" ),
83+ reconfigureResult : validTestPlugin ("alpha" ),
84+ }
85+ loader .lookups ["alpha" ] = newTestSymbolLookup (plugin )
86+ h := NewForTest (loader )
87+
88+ h .ApplyConfig (context .Background (), & config.Config {
89+ Plugins : config.PluginsConfig {
90+ Enabled : true ,
91+ Dir : makePluginDir (t , "alpha" ),
92+ },
93+ })
94+
95+ if plugin .registerCalls != 0 || loader .openCalls != 0 {
96+ t .Fatalf ("calls = register %d open %d, want 0" , plugin .registerCalls , loader .openCalls )
97+ }
98+ if len (h .Snapshot ().records ) != 0 {
99+ t .Fatalf ("Snapshot records = %d, want 0" , len (h .Snapshot ().records ))
100+ }
101+ }
102+
70103func TestPluginLoadedTracksLoadedPluginAfterDisabled (t * testing.T ) {
71104 disabled := false
72105 loader := newTestSymbolLoader ()
@@ -83,6 +116,7 @@ func TestPluginLoadedTracksLoadedPluginAfterDisabled(t *testing.T) {
83116 Plugins : config.PluginsConfig {
84117 Enabled : true ,
85118 Dir : pluginsDir ,
119+ Configs : enabledPluginConfigs ("alpha" ),
86120 },
87121 })
88122
@@ -136,6 +170,7 @@ func TestHostUnloadPluginTargetsOnlyRequestedPlugin(t *testing.T) {
136170 Plugins : config.PluginsConfig {
137171 Enabled : true ,
138172 Dir : makePluginDir (t , "alpha" , "bravo" ),
173+ Configs : enabledPluginConfigs ("alpha" , "bravo" ),
139174 },
140175 }
141176
@@ -191,6 +226,7 @@ func TestHostApplyConfigRegistersPluginThinkingApplier(t *testing.T) {
191226 Plugins : config.PluginsConfig {
192227 Enabled : true ,
193228 Dir : makePluginDir (t , "alpha" ),
229+ Configs : enabledPluginConfigs ("alpha" ),
194230 },
195231 }
196232 t .Cleanup (func () {
@@ -240,6 +276,7 @@ func TestHostApplyConfigRegistersInterceptorOnlyPlugin(t *testing.T) {
240276 Plugins : config.PluginsConfig {
241277 Enabled : true ,
242278 Dir : makePluginDir (t , "alpha" ),
279+ Configs : enabledPluginConfigs ("alpha" ),
243280 },
244281 })
245282
@@ -282,6 +319,7 @@ func TestHostApplyConfigDispatchesInterceptorRPCMethods(t *testing.T) {
282319 Plugins : config.PluginsConfig {
283320 Enabled : true ,
284321 Dir : makePluginDir (t , "alpha" ),
322+ Configs : enabledPluginConfigs ("alpha" ),
285323 },
286324 })
287325
@@ -488,6 +526,7 @@ func TestHostApplyConfig_ReconfigureCalledOnReload(t *testing.T) {
488526 Plugins : config.PluginsConfig {
489527 Enabled : true ,
490528 Dir : makePluginDir (t , "alpha" ),
529+ Configs : enabledPluginConfigs ("alpha" ),
491530 },
492531 }
493532
@@ -529,6 +568,7 @@ func TestRegisteredPluginsIncludesMetadataAndOAuthCapability(t *testing.T) {
529568 Plugins : config.PluginsConfig {
530569 Enabled : true ,
531570 Dir : makePluginDir (t , "alpha" ),
571+ Configs : enabledPluginConfigs ("alpha" ),
532572 },
533573 })
534574
@@ -589,6 +629,7 @@ func TestHostApplyConfig_PanicFusesPluginForProcessLifetime(t *testing.T) {
589629 Plugins : config.PluginsConfig {
590630 Enabled : true ,
591631 Dir : makePluginDir (t , "alpha" ),
632+ Configs : enabledPluginConfigs ("alpha" ),
592633 },
593634 }
594635
@@ -674,6 +715,7 @@ func TestHostApplyConfigSerializesLifecycleCalls(t *testing.T) {
674715 Plugins : config.PluginsConfig {
675716 Enabled : true ,
676717 Dir : makePluginDir (t , "alpha" ),
718+ Configs : enabledPluginConfigs ("alpha" ),
677719 },
678720 }
679721
@@ -896,6 +938,7 @@ func newBlockingOpenHost(t *testing.T) (*Host, *config.Config, <-chan struct{},
896938 Plugins : config.PluginsConfig {
897939 Enabled : true ,
898940 Dir : makePluginDir (t , "alpha" ),
941+ Configs : enabledPluginConfigs ("alpha" ),
899942 },
900943 }
901944 return h , cfg , openStarted , releaseOpen
@@ -928,6 +971,7 @@ func newBlockingRegisterHost(t *testing.T) (*Host, *config.Config, <-chan struct
928971 Plugins : config.PluginsConfig {
929972 Enabled : true ,
930973 Dir : makePluginDir (t , "alpha" ),
974+ Configs : enabledPluginConfigs ("alpha" ),
931975 },
932976 }
933977 return h , cfg , registerStarted , releaseRegister
0 commit comments