mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 04:53:59 +08:00
Plugins: Follow root level dist and siblings when walking file system (#78042)
* simplify * add comments * tidy up * remove line * update comment * fix pfs test * fix err import * delete code
This commit is contained in:
@ -336,6 +336,45 @@ func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestFinder_getAbsPluginJSONPaths_PluginClass(t *testing.T) {
|
||||
t.Run("When a dist folder exists as a direct child of the plugins path, it will always be resolved", func(t *testing.T) {
|
||||
dir, err := filepath.Abs("../../testdata/pluginRootWithDist")
|
||||
require.NoError(t, err)
|
||||
|
||||
tcs := []struct {
|
||||
name string
|
||||
followDist bool
|
||||
expected []string
|
||||
}{
|
||||
{
|
||||
name: "When followDistFolder is enabled, a nested dist folder will also be resolved",
|
||||
followDist: true,
|
||||
expected: []string{
|
||||
filepath.Join(dir, "datasource/plugin.json"),
|
||||
filepath.Join(dir, "dist/plugin.json"),
|
||||
filepath.Join(dir, "panel/dist/plugin.json"),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "When followDistFolder is disabled, a nested dist folder will not be resolved",
|
||||
followDist: false,
|
||||
expected: []string{
|
||||
filepath.Join(dir, "datasource/plugin.json"),
|
||||
filepath.Join(dir, "dist/plugin.json"),
|
||||
filepath.Join(dir, "panel/src/plugin.json"),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
pluginBundles, err := NewLocalFinder(false).getAbsPluginJSONPaths(dir, tc.followDist)
|
||||
require.NoError(t, err)
|
||||
|
||||
sort.Strings(pluginBundles)
|
||||
require.Equal(t, tc.expected, pluginBundles)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var fsComparer = cmp.Comparer(func(fs1 plugins.FS, fs2 plugins.FS) bool {
|
||||
fs1Files, err := fs1.Files()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user