From 08a93ebdc437c971661e33595cec40f3cd5273db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Fri, 1 Dec 2023 16:59:53 +0100 Subject: [PATCH] rpmmd: delete unused `ResolveConflictsExclude()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This method is no longer used by any code, let's delete it. Signed-off-by: Tomáš Hozza --- pkg/rpmmd/repository.go | 19 ------------- pkg/rpmmd/test/repository_test.go | 46 ------------------------------- 2 files changed, 65 deletions(-) diff --git a/pkg/rpmmd/repository.go b/pkg/rpmmd/repository.go index 6c879ac9bd..b185864e0c 100644 --- a/pkg/rpmmd/repository.go +++ b/pkg/rpmmd/repository.go @@ -137,25 +137,6 @@ func (ps PackageSet) Append(other PackageSet) PackageSet { return ps } -// ResolveConflictsExclude resolves conflicting Include and Exclude package lists -// content by deleting packages listed as Excluded from the Include list. -func (ps PackageSet) ResolveConflictsExclude() PackageSet { - excluded := map[string]struct{}{} - for _, pkg := range ps.Exclude { - excluded[pkg] = struct{}{} - } - - newInclude := []string{} - for _, pkg := range ps.Include { - _, found := excluded[pkg] - if !found { - newInclude = append(newInclude, pkg) - } - } - ps.Include = newInclude - return ps -} - // TODO: the public API of this package should not be reused for serialization. type PackageSpec struct { Name string `json:"name"` diff --git a/pkg/rpmmd/test/repository_test.go b/pkg/rpmmd/test/repository_test.go index 5d5db7e932..58f0b9bbd0 100644 --- a/pkg/rpmmd/test/repository_test.go +++ b/pkg/rpmmd/test/repository_test.go @@ -2,7 +2,6 @@ package rpmmdtests import ( "encoding/json" - "fmt" "path/filepath" "reflect" "testing" @@ -147,51 +146,6 @@ func Test_LoadAllRepositories(t *testing.T) { } } -func TestPackageSetResolveConflictExclude(t *testing.T) { - tests := []struct { - got rpmmd.PackageSet - want rpmmd.PackageSet - }{ - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - }, - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "dnf"}, - Exclude: []string{"microcode_ctl"}, - }, - }, - { - got: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{}, - }, - want: rpmmd.PackageSet{ - Include: []string{"kernel", "microcode_ctl", "dnf"}, - Exclude: []string{}, - }, - }, - } - for idx, tt := range tests { - t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) { - if !reflect.DeepEqual(tt.got.ResolveConflictsExclude(), tt.want) { - t.Errorf("ResolveConflictExclude() returned unexpected result got: %#v\n want: %#v", tt.got.ResolveConflictsExclude(), tt.want) - } - }) - } -} - func TestOldWorkerRepositoryCompatUnmarshal(t *testing.T) { testCases := []struct { repoJSON []byte