Plugins: Standardize Golang enum naming convention (#69449)
* standardize enum pattern * fix up
This commit is contained in:
@@ -24,7 +24,7 @@ func ProvideService(cdn *pluginscdn.Service) *Service {
|
||||
|
||||
// Base returns the base path for the specified plugin.
|
||||
func (s *Service) Base(pluginJSON plugins.JSONData, class plugins.Class, pluginDir string) (string, error) {
|
||||
if class == plugins.Core {
|
||||
if class == plugins.ClassCore {
|
||||
return path.Join("public/app/plugins", string(pluginJSON.Type), filepath.Base(pluginDir)), nil
|
||||
}
|
||||
if s.cdn.PluginSupported(pluginJSON.ID) {
|
||||
@@ -35,7 +35,7 @@ func (s *Service) Base(pluginJSON plugins.JSONData, class plugins.Class, pluginD
|
||||
|
||||
// Module returns the module.js path for the specified plugin.
|
||||
func (s *Service) Module(pluginJSON plugins.JSONData, class plugins.Class, pluginDir string) (string, error) {
|
||||
if class == plugins.Core {
|
||||
if class == plugins.ClassCore {
|
||||
return path.Join("app/plugins", string(pluginJSON.Type), filepath.Base(pluginDir), "module"), nil
|
||||
}
|
||||
if s.cdn.PluginSupported(pluginJSON.ID) {
|
||||
|
||||
@@ -56,29 +56,29 @@ func TestService(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Base", func(t *testing.T) {
|
||||
base, err := svc.Base(jsonData["one"], plugins.External, extPath("one"))
|
||||
base, err := svc.Base(jsonData["one"], plugins.ClassExternal, extPath("one"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "plugin-cdn/one/1.0.0/public/plugins/one", base)
|
||||
|
||||
base, err = svc.Base(jsonData["two"], plugins.External, extPath("two"))
|
||||
base, err = svc.Base(jsonData["two"], plugins.ClassExternal, extPath("two"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "public/plugins/two", base)
|
||||
|
||||
base, err = svc.Base(jsonData["table-old"], plugins.Core, tableOldPath)
|
||||
base, err = svc.Base(jsonData["table-old"], plugins.ClassCore, tableOldPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "public/app/plugins/table-old", base)
|
||||
})
|
||||
|
||||
t.Run("Module", func(t *testing.T) {
|
||||
module, err := svc.Module(jsonData["one"], plugins.External, extPath("one"))
|
||||
module, err := svc.Module(jsonData["one"], plugins.ClassExternal, extPath("one"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "plugin-cdn/one/1.0.0/public/plugins/one/module", module)
|
||||
|
||||
module, err = svc.Module(jsonData["two"], plugins.External, extPath("two"))
|
||||
module, err = svc.Module(jsonData["two"], plugins.ClassExternal, extPath("two"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "plugins/two/module", module)
|
||||
|
||||
module, err = svc.Module(jsonData["table-old"], plugins.Core, tableOldPath)
|
||||
module, err = svc.Module(jsonData["table-old"], plugins.ClassCore, tableOldPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "app/plugins/table-old/module", module)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user