Chore: clean up angular related test (#110659)
This commit is contained in:
@@ -1186,42 +1186,34 @@ func TestLoader_Load_Angular(t *testing.T) {
|
||||
},
|
||||
DiscoverFunc: sources.NewLocalSource(plugins.ClassExternal, []string{filepath.Join(testDataDir(t), "valid-v2-signature")}).Discover,
|
||||
}
|
||||
for _, cfgTc := range []struct {
|
||||
name string
|
||||
cfg *config.PluginManagementCfg
|
||||
cfg := &config.PluginManagementCfg{}
|
||||
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
angularInspector angularinspector.Inspector
|
||||
shouldLoad bool
|
||||
}{
|
||||
{name: "angular support enabled", cfg: &config.PluginManagementCfg{}},
|
||||
{name: "angular support disabled", cfg: &config.PluginManagementCfg{}},
|
||||
{
|
||||
name: "should not load an angular plugin",
|
||||
angularInspector: angularinspector.AlwaysAngularFakeInspector,
|
||||
// angular plugins should never load
|
||||
shouldLoad: false,
|
||||
},
|
||||
{
|
||||
name: "should load a non angular plugin",
|
||||
angularInspector: angularinspector.NeverAngularFakeInspector,
|
||||
// non-angular plugins should always load
|
||||
shouldLoad: true,
|
||||
},
|
||||
} {
|
||||
t.Run(cfgTc.name, func(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
angularInspector angularinspector.Inspector
|
||||
shouldLoad bool
|
||||
}{
|
||||
{
|
||||
name: "angular plugin",
|
||||
angularInspector: angularinspector.AlwaysAngularFakeInspector,
|
||||
// angular plugins should load only if allowed by the cfg
|
||||
shouldLoad: false,
|
||||
},
|
||||
{
|
||||
name: "non angular plugin",
|
||||
angularInspector: angularinspector.NeverAngularFakeInspector,
|
||||
// non-angular plugins should always load
|
||||
shouldLoad: true,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
l := newLoaderWithOpts(t, cfgTc.cfg, loaderDepOpts{angularInspector: tc.angularInspector})
|
||||
p, err := l.Load(context.Background(), fakePluginSource)
|
||||
require.NoError(t, err)
|
||||
if tc.shouldLoad {
|
||||
require.Len(t, p, 1, "plugin should have been loaded")
|
||||
} else {
|
||||
require.Empty(t, p, "plugin shouldn't have been loaded")
|
||||
}
|
||||
})
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
l := newLoaderWithOpts(t, cfg, loaderDepOpts{angularInspector: tc.angularInspector})
|
||||
p, err := l.Load(context.Background(), fakePluginSource)
|
||||
require.NoError(t, err)
|
||||
if tc.shouldLoad {
|
||||
require.Len(t, p, 1, "plugin should have been loaded")
|
||||
} else {
|
||||
require.Empty(t, p, "plugin shouldn't have been loaded")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user