repos: make clearer why newRepoRegistry is a var

This commit reworks the `newRepoRegistry` func so that its easier
to see that it is a variable so that it can be overriden by the
tests. In the tests we want to use the `testrepos` we get from
images and in the real implementation we want to use the full
repo loader with search-paths and extra repos.
This commit is contained in:
Michael Vogt 2025-02-11 16:51:48 +01:00
parent 5f6d59013f
commit e2aeecec8e

View file

@ -53,7 +53,7 @@ func parseExtraRepo(extraRepo string) ([]rpmmd.RepoConfig, error) {
}, nil
}
var newRepoRegistry = func(dataDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) {
func newRepoRegistryImpl(dataDir string, extraRepos []string) (*reporegistry.RepoRegistry, error) {
var dataDirs []string
if dataDir != "" {
dataDirs = []string{dataDir}
@ -87,3 +87,6 @@ var newRepoRegistry = func(dataDir string, extraRepos []string) (*reporegistry.R
return reporegistry.NewFromDistrosRepoConfigs(conf), nil
}
// this is a variable to make it overridable in tests
var newRepoRegistry = newRepoRegistryImpl