You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: local_test.go
    path of file: ./repos/grafana/pkg/plugins/manager/loader/finder
    
    the code of the file until where you have to start completion: package finder

import (
	"context"
	"errors"
	"os"
	"path/filepath"
	"sort"
	"testing"

	"github.com/google/go-cmp/cmp"
	"github.com/stretchr/testify/require"

	"github.com/grafana/grafana/pkg/plugins"
	"github.com/grafana/grafana/pkg/plugins/manager/fakes"
	"github.com/grafana/grafana/pkg/services/featuremgmt"
	"github.com/grafana/grafana/pkg/util"
)

func TestFinder_Find(t *testing.T) {
	testData, err := filepath.Abs("../../testdata")
	if err != nil {
		require.NoError(t, err)
	}

	testCases := []struct {
		name            string
		pluginDirs      []string
		pluginClass     plugins.Class
		expectedBundles []*plugins.FoundBundle
		err             error
	}{
		{
			name:       "Dir with single plugin",
			pluginDirs: []string{filepath.Join(testData, "valid-v2-signature")},
			expectedBundles: []*plugins.FoundBundle{
				{
					Primary: plugins.FoundPlugin{
						JSONData: plugins.JSONData{
							ID:   "test-datasource",
							Type: plugins.TypeDataSource,
							Name: "Test",
							Info: plugins.Info{
								Author: plugins.InfoLink{
									Name: "Will Browne",
									URL:  "https://willbrowne.com",
								},
								Description: "Test",
								Version:     "1.0.0",
							},
							Dependencies: plugins.Dependencies{
								GrafanaVersion: "*",
								Plugins:        []plugins.Dependency{},
							},
							State:      plugins.ReleaseStateAlpha,
							Backend:    true,
							Executab
    
func TestFinder_getAbsPluginJSONPaths(t *testing.T) {
	t.Run("When scanning a folder that doesn't exists shouldn't return an error", func(t *testing.T) {
		origWalk := walk
		walk = func(path string, followSymlinks, detectSymlinkInfiniteLoop, followDistFolder bool, walkFn util.WalkFunc) error {
			return walkFn(path, nil, os.ErrNotExist)
		}
		t.Cleanup(func() {
			walk = origWalk
		})

		finder := NewLocalFinder(false, featuremgmt.WithFeatures())
		paths, err := finder.getAbsPluginJSONPaths("test", true)
		require.NoError(t, err)
		require.Empty(t, paths)
	})

	t.Run("When scanning a folder that lacks permission shouldn't return an error", func(t *testing.T) {
		origWalk := walk
		walk = func(path string, followSymlinks, detectSymlinkInfiniteLoop, followDistFolder bool, walkFn util.WalkFunc) error {
			return walkFn(path, nil, os.ErrPermission)
		}
		t.Cleanup(func() {
			walk = origWalk
		})

		finder := NewLocalFinder(false, featuremgmt.WithFeatures())
		paths, err := finder.getAbsPluginJSONPaths("test", true)
		require.NoError(t, err)
		require.Empty(t, paths)
	})

	t.Run("When scanning a folder that returns a non-handled error should return that error", func(t *testing.T) {
		origWalk := walk
		walk = func(path string, followSymlinks, detectSymlinkInfiniteLoop, followDistFolder bool, walkFn util.WalkFunc) error {
			return walkFn(path, nil, errors.New("random error"))
		}
		t.Cleanup(func() {
			walk = origWalk
		})

		finder := NewLocalFinder(false, featuremgmt.WithFeatures())
		paths, err := finder.getAbsPluginJSONPaths("test", true)
		require.Error(t, err)
		require.Empty(t, paths)
	})

	t.Run("The followDistFolder state controls whether certain folders are followed", 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, only the nested dist folder will be followed",
				followDist: true,
				expected: []string{
					filepath.Join(dir, "dist/plugin.json"),
				},
			},
			{
				name:       "When followDistFolder is disabled, no dist folders will be followed",
				followDist: false,
				expected: []string{
					filepath.Join(dir, "datasource/plugin.json"),
					filepath.Join(dir, "panel/src/plugin.json"),
				},
			},
		}
		for _, tc := range tcs {
			pluginBundles, err := NewLocalFinder(false, featuremgmt.WithFeatures()).getAbsPluginJSONPaths(dir, tc.followDist)
			require.NoError(t, err)

			sort.Strings(pluginBundles)
			require.Equal(t, tc.expected, pluginBundles)
		}
	})
}