From 2d541c434b111a705f29ba30e91e3ae2865647f5 Mon Sep 17 00:00:00 2001 From: Shunsuke Suzuki Date: Mon, 16 Oct 2023 09:58:36 +0900 Subject: [PATCH] test(versiongetter): add tests --- pkg/controller/wire.go | 10 +- pkg/controller/wire_gen.go | 8 +- pkg/versiongetter/cargo_test.go | 127 ++++++++++++++++ pkg/versiongetter/{get.go => fuzzy_getter.go} | 32 +--- pkg/versiongetter/fuzzy_getter_test.go | 85 +++++++++++ pkg/versiongetter/general.go | 54 +++++++ pkg/versiongetter/getter.go | 43 ------ pkg/versiongetter/github_tag_test.go | 143 ++++++++++++++++++ pkg/versiongetter/mock_cargo.go | 32 ++++ pkg/versiongetter/mock_fuzzy_getter.go | 22 +++ pkg/versiongetter/mock_github_tag.go | 31 ++++ pkg/versiongetter/mock_version_getter.go | 35 +++++ pkg/versiongetter/version_getter.go | 13 ++ 13 files changed, 562 insertions(+), 73 deletions(-) create mode 100644 pkg/versiongetter/cargo_test.go rename pkg/versiongetter/{get.go => fuzzy_getter.go} (65%) create mode 100644 pkg/versiongetter/fuzzy_getter_test.go create mode 100644 pkg/versiongetter/general.go delete mode 100644 pkg/versiongetter/getter.go create mode 100644 pkg/versiongetter/github_tag_test.go create mode 100644 pkg/versiongetter/mock_cargo.go create mode 100644 pkg/versiongetter/mock_fuzzy_getter.go create mode 100644 pkg/versiongetter/mock_github_tag.go create mode 100644 pkg/versiongetter/mock_version_getter.go create mode 100644 pkg/versiongetter/version_getter.go diff --git a/pkg/controller/wire.go b/pkg/controller/wire.go index 9155bbbde..0b0809c7b 100644 --- a/pkg/controller/wire.go +++ b/pkg/controller/wire.go @@ -206,7 +206,10 @@ func InitializeGenerateCommandController(ctx context.Context, param *config.Para versiongetter.NewFuzzy, wire.Bind(new(generate.FuzzyGetter), new(*versiongetter.FuzzyGetter)), ), - versiongetter.NewGenerator, + wire.NewSet( + versiongetter.NewGeneralVersionGetter, + wire.Bind(new(versiongetter.VersionGetter), new(*versiongetter.GeneralVersionGetter)), + ), versiongetter.NewCargo, versiongetter.NewGitHubRelease, versiongetter.NewGitHubTag, @@ -788,7 +791,10 @@ func InitializeUpdateCommandController(ctx context.Context, param *config.Param, wire.Bind(new(update.FuzzyFinder), new(*fuzzyfinder.Finder)), wire.Bind(new(versiongetter.FuzzyFinder), new(*fuzzyfinder.Finder)), ), - versiongetter.NewGenerator, + wire.NewSet( + versiongetter.NewGeneralVersionGetter, + wire.Bind(new(versiongetter.VersionGetter), new(*versiongetter.GeneralVersionGetter)), + ), versiongetter.NewCargo, versiongetter.NewGitHubRelease, versiongetter.NewGitHubTag, diff --git a/pkg/controller/wire_gen.go b/pkg/controller/wire_gen.go index ac2fba8ff..1273edbb4 100644 --- a/pkg/controller/wire_gen.go +++ b/pkg/controller/wire_gen.go @@ -108,8 +108,8 @@ func InitializeGenerateCommandController(ctx context.Context, param *config.Para cargoVersionGetter := versiongetter.NewCargo(clientImpl) gitHubTagVersionGetter := versiongetter.NewGitHubTag(repositoriesService) gitHubReleaseVersionGetter := versiongetter.NewGitHubRelease(repositoriesService) - generator := versiongetter.NewGenerator(cargoVersionGetter, gitHubTagVersionGetter, gitHubReleaseVersionGetter) - fuzzyGetter := versiongetter.NewFuzzy(fuzzyfinderFinder, generator) + generalVersionGetter := versiongetter.NewGeneralVersionGetter(cargoVersionGetter, gitHubTagVersionGetter, gitHubReleaseVersionGetter) + fuzzyGetter := versiongetter.NewFuzzy(fuzzyfinderFinder, generalVersionGetter) controller := generate.New(configFinder, configReaderImpl, installerImpl, repositoriesService, fs, fuzzyfinderFinder, clientImpl, fuzzyGetter) return controller } @@ -282,8 +282,8 @@ func InitializeUpdateCommandController(ctx context.Context, param *config.Param, cargoVersionGetter := versiongetter.NewCargo(clientImpl) gitHubTagVersionGetter := versiongetter.NewGitHubTag(repositoriesService) gitHubReleaseVersionGetter := versiongetter.NewGitHubRelease(repositoriesService) - generator := versiongetter.NewGenerator(cargoVersionGetter, gitHubTagVersionGetter, gitHubReleaseVersionGetter) - fuzzyGetter := versiongetter.NewFuzzy(fuzzyfinderFinder, generator) + generalVersionGetter := versiongetter.NewGeneralVersionGetter(cargoVersionGetter, gitHubTagVersionGetter, gitHubReleaseVersionGetter) + fuzzyGetter := versiongetter.NewFuzzy(fuzzyfinderFinder, generalVersionGetter) osEnv := osenv.New() linker := link.New() controllerImpl := which.New(param, configFinder, configReaderImpl, installerImpl, rt, osEnv, fs, linker) diff --git a/pkg/versiongetter/cargo_test.go b/pkg/versiongetter/cargo_test.go new file mode 100644 index 000000000..59fd40890 --- /dev/null +++ b/pkg/versiongetter/cargo_test.go @@ -0,0 +1,127 @@ +package versiongetter_test + +import ( + "context" + "testing" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" + "github.com/aquaproj/aqua/v2/pkg/versiongetter" + "github.com/google/go-cmp/cmp" +) + +func TestCargoVersionGetter_Get(t *testing.T) { + t.Parallel() + data := []struct { + name string + versions map[string][]string + pkg *registry.PackageInfo + filters []*versiongetter.Filter + isErr bool + version string + }{ + { + name: "normal", + filters: []*versiongetter.Filter{ + {}, + }, + versions: map[string][]string{ + "crates.io/skim": { + "3.0.0", + "2.0.0", + "1.0.0", + }, + }, + pkg: ®istry.PackageInfo{ + Crate: "crates.io/skim", + }, + version: "3.0.0", + }, + } + + ctx := context.Background() + for _, d := range data { + d := d + t.Run(d.name, func(t *testing.T) { + t.Parallel() + cargoClient := versiongetter.NewMockCargoClient(d.versions) + cargoGetter := versiongetter.NewCargo(cargoClient) + version, err := cargoGetter.Get(ctx, d.pkg, d.filters) + if err != nil { + if d.isErr { + return + } + t.Fatal(err) + } + if d.isErr { + t.Fatal("error must be returned") + } + if version != d.version { + t.Fatalf("wanted %s, got %s", d.version, version) + } + }) + } +} + +func TestCargoVersionGetter_List(t *testing.T) { + t.Parallel() + data := []struct { + name string + versions map[string][]string + pkg *registry.PackageInfo + filters []*versiongetter.Filter + isErr bool + items []*fuzzyfinder.Item + }{ + { + name: "normal", + filters: []*versiongetter.Filter{ + {}, + }, + versions: map[string][]string{ + "crates.io/skim": { + "3.0.0", + "2.0.0", + "1.0.0", + }, + }, + pkg: ®istry.PackageInfo{ + Crate: "crates.io/skim", + }, + items: []*fuzzyfinder.Item{ + { + Item: "3.0.0", + }, + { + Item: "2.0.0", + }, + { + Item: "1.0.0", + }, + }, + }, + } + + ctx := context.Background() + for _, d := range data { + d := d + t.Run(d.name, func(t *testing.T) { + t.Parallel() + cargoClient := versiongetter.NewMockCargoClient(d.versions) + cargoGetter := versiongetter.NewCargo(cargoClient) + items, err := cargoGetter.List(ctx, d.pkg, d.filters) + if err != nil { + if d.isErr { + return + } + t.Fatal(err) + } + if d.isErr { + t.Fatal("error must be returned") + } + if diff := cmp.Diff(items, d.items); diff != "" { + t.Fatalf(diff) + } + }) + } +} diff --git a/pkg/versiongetter/get.go b/pkg/versiongetter/fuzzy_getter.go similarity index 65% rename from pkg/versiongetter/get.go rename to pkg/versiongetter/fuzzy_getter.go index 02be8f202..7669cbc4a 100644 --- a/pkg/versiongetter/get.go +++ b/pkg/versiongetter/fuzzy_getter.go @@ -11,30 +11,16 @@ import ( type FuzzyGetter struct { fuzzyFinder FuzzyFinder - gen *Generator + getter VersionGetter } -func NewFuzzy(finder FuzzyFinder, gen *Generator) *FuzzyGetter { +func NewFuzzy(finder FuzzyFinder, getter VersionGetter) *FuzzyGetter { return &FuzzyGetter{ fuzzyFinder: finder, - gen: gen, + getter: getter, } } -type MockFuzzyGetter struct { - versions map[string]string -} - -func NewMockFuzzyGetter(versions map[string]string) *MockFuzzyGetter { - return &MockFuzzyGetter{ - versions: versions, - } -} - -func (g *MockFuzzyGetter) Get(ctx context.Context, _ *logrus.Entry, pkg *registry.PackageInfo, currentVersion string, useFinder bool) string { - return g.versions[pkg.GetName()] -} - type FuzzyFinder interface { Find(items []*fuzzyfinder.Item, hasPreview bool) (int, error) FindMulti(items []*fuzzyfinder.Item, hasPreview bool) ([]int, error) @@ -46,16 +32,14 @@ func (g *FuzzyGetter) Get(ctx context.Context, _ *logrus.Entry, pkg *registry.Pa return "" } - versionGetter := g.gen.Get(pkg) - if versionGetter == nil { - return "" - } - if useFinder { //nolint:nestif - versions, err := versionGetter.List(ctx, pkg, filters) + versions, err := g.getter.List(ctx, pkg, filters) if err != nil { return "" } + if versions == nil { + return "" + } currentVersionIndex := 0 if currentVersion != "" { for i, version := range versions { @@ -76,7 +60,7 @@ func (g *FuzzyGetter) Get(ctx context.Context, _ *logrus.Entry, pkg *registry.Pa return versions[idx].Item } - version, err := versionGetter.Get(ctx, pkg, filters) + version, err := g.getter.Get(ctx, pkg, filters) if err != nil { return "" } diff --git a/pkg/versiongetter/fuzzy_getter_test.go b/pkg/versiongetter/fuzzy_getter_test.go new file mode 100644 index 000000000..c33f1e7d4 --- /dev/null +++ b/pkg/versiongetter/fuzzy_getter_test.go @@ -0,0 +1,85 @@ +package versiongetter_test + +import ( + "context" + "testing" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" + "github.com/aquaproj/aqua/v2/pkg/versiongetter" + "github.com/sirupsen/logrus" +) + +func TestFuzzyGetter_Get(t *testing.T) { + t.Parallel() + data := []struct { + name string + pkg *registry.PackageInfo + currentVersion string + useFinder bool + version string + idxs []int + versions map[string][]*fuzzyfinder.Item + }{ + { + name: "normal", + pkg: ®istry.PackageInfo{ + RepoOwner: "suzuki-shunsuke", + RepoName: "tfcmt", + }, + currentVersion: "v2.0.0", + version: "v4.6.0", + versions: map[string][]*fuzzyfinder.Item{ + "suzuki-shunsuke/tfcmt": { + { + Item: "v4.6.0", + }, + { + Item: "v3.0.0", + }, + { + Item: "v2.0.0", + }, + }, + }, + }, + { + name: "finder", + pkg: ®istry.PackageInfo{ + RepoOwner: "suzuki-shunsuke", + RepoName: "tfcmt", + }, + useFinder: true, + idxs: []int{1}, + currentVersion: "v2.0.0", + version: "v3.0.0", + versions: map[string][]*fuzzyfinder.Item{ + "suzuki-shunsuke/tfcmt": { + { + Item: "v4.6.0", + }, + { + Item: "v3.0.0", + }, + { + Item: "v2.0.0", + }, + }, + }, + }, + } + logE := logrus.NewEntry(logrus.New()) + for _, d := range data { + d := d + t.Run(d.name, func(t *testing.T) { + t.Parallel() + finder := fuzzyfinder.NewMock(d.idxs, nil) + vg := versiongetter.NewMockVersionGetter(d.versions) + fg := versiongetter.NewFuzzy(finder, vg) + version := fg.Get(context.Background(), logE, d.pkg, d.currentVersion, d.useFinder) + if version != d.version { + t.Fatalf("wanted %s, got %s", d.version, version) + } + }) + } +} diff --git a/pkg/versiongetter/general.go b/pkg/versiongetter/general.go new file mode 100644 index 000000000..5d317021d --- /dev/null +++ b/pkg/versiongetter/general.go @@ -0,0 +1,54 @@ +package versiongetter + +import ( + "context" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" +) + +type GeneralVersionGetter struct { + cargo *CargoVersionGetter + ghTag *GitHubTagVersionGetter + ghRelease *GitHubReleaseVersionGetter +} + +func NewGeneralVersionGetter(cargo *CargoVersionGetter, ghTag *GitHubTagVersionGetter, ghRelease *GitHubReleaseVersionGetter) *GeneralVersionGetter { + return &GeneralVersionGetter{ + cargo: cargo, + ghTag: ghTag, + ghRelease: ghRelease, + } +} + +func (g *GeneralVersionGetter) Get(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) (string, error) { + getter := g.get(pkg) + if getter == nil { + return "", nil + } + return getter.Get(ctx, pkg, filters) //nolint:wrapcheck +} + +func (g *GeneralVersionGetter) List(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) ([]*fuzzyfinder.Item, error) { + getter := g.get(pkg) + if getter == nil { + return nil, nil + } + return getter.List(ctx, pkg, filters) //nolint:wrapcheck +} + +func (g *GeneralVersionGetter) get(pkg *registry.PackageInfo) VersionGetter { + if pkg.Type == "cargo" { + return g.cargo + } + if g.ghTag == nil { + return nil + } + if !pkg.HasRepo() { + return nil + } + if pkg.VersionSource == "github_tag" { + return g.ghTag + } + return g.ghRelease +} diff --git a/pkg/versiongetter/getter.go b/pkg/versiongetter/getter.go deleted file mode 100644 index b5912adcc..000000000 --- a/pkg/versiongetter/getter.go +++ /dev/null @@ -1,43 +0,0 @@ -package versiongetter - -import ( - "context" - - "github.com/aquaproj/aqua/v2/pkg/config/registry" - "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" -) - -type VersionGetter interface { - Get(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) (string, error) - List(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) ([]*fuzzyfinder.Item, error) -} - -type Generator struct { - cargo *CargoVersionGetter - ghTag *GitHubTagVersionGetter - ghRelease *GitHubReleaseVersionGetter -} - -func NewGenerator(cargo *CargoVersionGetter, ghTag *GitHubTagVersionGetter, ghRelease *GitHubReleaseVersionGetter) *Generator { - return &Generator{ - cargo: cargo, - ghTag: ghTag, - ghRelease: ghRelease, - } -} - -func (g *Generator) Get(pkg *registry.PackageInfo) VersionGetter { - if pkg.Type == "cargo" { - return g.cargo - } - if g.ghTag == nil { - return nil - } - if !pkg.HasRepo() { - return nil - } - if pkg.VersionSource == "github_tag" { - return g.ghTag - } - return g.ghRelease -} diff --git a/pkg/versiongetter/github_tag_test.go b/pkg/versiongetter/github_tag_test.go new file mode 100644 index 000000000..8c38659df --- /dev/null +++ b/pkg/versiongetter/github_tag_test.go @@ -0,0 +1,143 @@ +package versiongetter_test + +import ( + "context" + "testing" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" + "github.com/aquaproj/aqua/v2/pkg/github" + "github.com/aquaproj/aqua/v2/pkg/ptr" + "github.com/aquaproj/aqua/v2/pkg/versiongetter" + "github.com/google/go-cmp/cmp" +) + +func TestGitHubTagVersionGetter_Get(t *testing.T) { + t.Parallel() + data := []struct { + name string + tags map[string][]*github.RepositoryTag + pkg *registry.PackageInfo + filters []*versiongetter.Filter + isErr bool + version string + }{ + { + name: "normal", + filters: []*versiongetter.Filter{ + {}, + }, + tags: map[string][]*github.RepositoryTag{ + "suzuki-shunsuke/tfcmt": { + { + Name: ptr.String("v3.0.0"), + }, + { + Name: ptr.String("v2.0.0"), + }, + { + Name: ptr.String("v1.0.0"), + }, + }, + }, + pkg: ®istry.PackageInfo{ + RepoOwner: "suzuki-shunsuke", + RepoName: "tfcmt", + }, + version: "v3.0.0", + }, + } + + ctx := context.Background() + for _, d := range data { + d := d + t.Run(d.name, func(t *testing.T) { + t.Parallel() + ghTagClient := versiongetter.NewMockGitHubTagClient(d.tags) + ghTagGetter := versiongetter.NewGitHubTag(ghTagClient) + version, err := ghTagGetter.Get(ctx, d.pkg, d.filters) + if err != nil { + if d.isErr { + return + } + t.Fatal(err) + } + if d.isErr { + t.Fatal("error must be returned") + } + if version != d.version { + t.Fatalf("wanted %s, got %s", d.version, version) + } + }) + } +} + +func TestGitHubTagVersionGetter_List(t *testing.T) { //nolint:funlen + t.Parallel() + data := []struct { + name string + tags map[string][]*github.RepositoryTag + pkg *registry.PackageInfo + filters []*versiongetter.Filter + isErr bool + items []*fuzzyfinder.Item + }{ + { + name: "normal", + filters: []*versiongetter.Filter{ + {}, + }, + tags: map[string][]*github.RepositoryTag{ + "suzuki-shunsuke/tfcmt": { + { + Name: ptr.String("v3.0.0"), + }, + { + Name: ptr.String("v2.0.0"), + }, + { + Name: ptr.String("v1.0.0"), + }, + }, + }, + pkg: ®istry.PackageInfo{ + RepoOwner: "suzuki-shunsuke", + RepoName: "tfcmt", + }, + items: []*fuzzyfinder.Item{ + { + Item: "v3.0.0", + }, + { + Item: "v2.0.0", + }, + { + Item: "v1.0.0", + }, + }, + }, + } + + ctx := context.Background() + for _, d := range data { + d := d + t.Run(d.name, func(t *testing.T) { + t.Parallel() + ghTagClient := versiongetter.NewMockGitHubTagClient(d.tags) + ghTagGetter := versiongetter.NewGitHubTag(ghTagClient) + items, err := ghTagGetter.List(ctx, d.pkg, d.filters) + if err != nil { + if d.isErr { + return + } + t.Fatal(err) + } + if d.isErr { + t.Fatal("error must be returned") + } + if diff := cmp.Diff(items, d.items); diff != "" { + t.Fatalf(diff) + } + }) + } +} diff --git a/pkg/versiongetter/mock_cargo.go b/pkg/versiongetter/mock_cargo.go new file mode 100644 index 000000000..671c5d0ce --- /dev/null +++ b/pkg/versiongetter/mock_cargo.go @@ -0,0 +1,32 @@ +package versiongetter + +import ( + "context" + "errors" +) + +type MockCargoClient struct { + versions map[string][]string +} + +func NewMockCargoClient(versions map[string][]string) *MockCargoClient { + return &MockCargoClient{ + versions: versions, + } +} + +func (g *MockCargoClient) ListVersions(ctx context.Context, crate string) ([]string, error) { + versions, ok := g.versions[crate] + if !ok { + return nil, errors.New("crate isn't found") + } + return versions, nil +} + +func (g *MockCargoClient) GetLatestVersion(ctx context.Context, crate string) (string, error) { + versions, ok := g.versions[crate] + if !ok { + return "", errors.New("crate isn't found") + } + return versions[0], nil +} diff --git a/pkg/versiongetter/mock_fuzzy_getter.go b/pkg/versiongetter/mock_fuzzy_getter.go new file mode 100644 index 000000000..d256bd35f --- /dev/null +++ b/pkg/versiongetter/mock_fuzzy_getter.go @@ -0,0 +1,22 @@ +package versiongetter + +import ( + "context" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/sirupsen/logrus" +) + +type MockFuzzyGetter struct { + versions map[string]string +} + +func NewMockFuzzyGetter(versions map[string]string) *MockFuzzyGetter { + return &MockFuzzyGetter{ + versions: versions, + } +} + +func (g *MockFuzzyGetter) Get(ctx context.Context, _ *logrus.Entry, pkg *registry.PackageInfo, currentVersion string, useFinder bool) string { + return g.versions[pkg.GetName()] +} diff --git a/pkg/versiongetter/mock_github_tag.go b/pkg/versiongetter/mock_github_tag.go new file mode 100644 index 000000000..23d33ed6a --- /dev/null +++ b/pkg/versiongetter/mock_github_tag.go @@ -0,0 +1,31 @@ +package versiongetter + +import ( + "context" + "errors" + "fmt" + + "github.com/aquaproj/aqua/v2/pkg/github" +) + +type MockGitHubTagClient struct { + tags map[string][]*github.RepositoryTag +} + +func NewMockGitHubTagClient(tags map[string][]*github.RepositoryTag) *MockGitHubTagClient { + return &MockGitHubTagClient{ + tags: tags, + } +} + +func (g *MockGitHubTagClient) ListTags(ctx context.Context, owner string, repo string, opts *github.ListOptions) ([]*github.RepositoryTag, *github.Response, error) { + tags, ok := g.tags[fmt.Sprintf("%s/%s", owner, repo)] + if !ok { + return nil, nil, errors.New("repository is not found") + } + m := (opts.Page + 1) * opts.PerPage + if m > len(tags) { + m = len(tags) + } + return tags[opts.Page*opts.PerPage : m], nil, nil +} diff --git a/pkg/versiongetter/mock_version_getter.go b/pkg/versiongetter/mock_version_getter.go new file mode 100644 index 000000000..59ce45acd --- /dev/null +++ b/pkg/versiongetter/mock_version_getter.go @@ -0,0 +1,35 @@ +package versiongetter + +import ( + "context" + "errors" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" +) + +type MockVersionGetter struct { + versions map[string][]*fuzzyfinder.Item +} + +func NewMockVersionGetter(versions map[string][]*fuzzyfinder.Item) *MockVersionGetter { + return &MockVersionGetter{ + versions: versions, + } +} + +func (g *MockVersionGetter) Get(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) (string, error) { + versions, ok := g.versions[pkg.GetName()] + if !ok { + return "", errors.New("version isn't found") + } + return versions[0].Item, nil +} + +func (g *MockVersionGetter) List(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) ([]*fuzzyfinder.Item, error) { + versions, ok := g.versions[pkg.GetName()] + if !ok { + return nil, errors.New("version isn't found") + } + return versions, nil +} diff --git a/pkg/versiongetter/version_getter.go b/pkg/versiongetter/version_getter.go new file mode 100644 index 000000000..271fef4c7 --- /dev/null +++ b/pkg/versiongetter/version_getter.go @@ -0,0 +1,13 @@ +package versiongetter + +import ( + "context" + + "github.com/aquaproj/aqua/v2/pkg/config/registry" + "github.com/aquaproj/aqua/v2/pkg/fuzzyfinder" +) + +type VersionGetter interface { + Get(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) (string, error) + List(ctx context.Context, pkg *registry.PackageInfo, filters []*Filter) ([]*fuzzyfinder.Item, error) +}