From 93c6336e24eaa6cc60301fbb0d66a0e30e0b4ec2 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 9 Mar 2022 19:11:27 +0100 Subject: [PATCH] reporegistry: remove unused ReposByArch() function Since all calls to `ReposByArch()` have been replaced by `ReposByArchName()`, remove the function and updates tests. --- internal/reporegistry/reporegistry.go | 11 ----------- internal/reporegistry/reporegistry_test.go | 21 +++++---------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/internal/reporegistry/reporegistry.go b/internal/reporegistry/reporegistry.go index 27a8f968e..a9ddf38c1 100644 --- a/internal/reporegistry/reporegistry.go +++ b/internal/reporegistry/reporegistry.go @@ -76,17 +76,6 @@ func (r *RepoRegistry) reposByImageTypeName(distro, arch, imageType string) ([]r return repositories, nil } -// ReposByArch returns a slice of rpmmd.RepoConfig instances, which should be used for building image types for the -// specific architecture. This includes by default all repositories without any image type tags specified. -// Depending on the `includeTagged` argument value, repositories with image type tags set will be added to the returned -// slice or not. -func (r *RepoRegistry) ReposByArch(arch distro.Arch, includeTagged bool) ([]rpmmd.RepoConfig, error) { - if arch.Distro() == nil || reflect.ValueOf(arch.Distro()).IsNil() { - return nil, fmt.Errorf("there is no distribution associated with the provided architecture") - } - return r.ReposByArchName(arch.Distro().Name(), arch.Name(), includeTagged) -} - // reposByArchName returns a slice of rpmmd.RepoConfig instances, which should be used for building image types for the // specific architecture and distribution. This includes by default all repositories without any image type tags specified. // Depending on the `includeTagged` argument value, repositories with image type tags set will be added to the returned diff --git a/internal/reporegistry/reporegistry_test.go b/internal/reporegistry/reporegistry_test.go index 09df8d5c7..0e0a8b197 100644 --- a/internal/reporegistry/reporegistry_test.go +++ b/internal/reporegistry/reporegistry_test.go @@ -277,21 +277,9 @@ func TestReposByArch(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := rr.ReposByArch(tt.args.arch, tt.args.taggedRepos) + got, err := rr.ReposByArchName(tt.args.arch.Distro().Name(), tt.args.arch.Name(), tt.args.taggedRepos) assert.Nil(t, err) - - var gotNames []string - for _, r := range got { - gotNames = append(gotNames, r.Name) - } - - if !reflect.DeepEqual(gotNames, tt.want) { - t.Errorf("ReposByArch() =\n got: %#v\n want: %#v", gotNames, tt.want) - } - - got, err = rr.ReposByArchName(tt.args.arch.Distro().Name(), tt.args.arch.Name(), tt.args.taggedRepos) - assert.Nil(t, err) - gotNames = []string{} + gotNames := []string{} for _, r := range got { gotNames = append(gotNames, r.Name) } @@ -309,12 +297,13 @@ func TestInvalidReposByArch(t *testing.T) { rr := getTestingRepoRegistry() ta := test_distro.TestArch{} + td := test_distro.TestDistro{} - repos, err := rr.ReposByArch(&ta, false) + repos, err := rr.ReposByArchName(td.Name(), ta.Name(), false) assert.Nil(t, repos) assert.NotNil(t, err) - repos, err = rr.ReposByArch(&ta, true) + repos, err = rr.ReposByArchName(td.Name(), ta.Name(), false) assert.Nil(t, repos) assert.NotNil(t, err) }