From afbd8f8ea02746624e037801d288da66df1a1314 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Wed, 2 Jun 2021 17:13:31 -0400 Subject: [PATCH] remove variadic functionality from intRef() test helper Signed-off-by: Alex Goodman --- syft/pkg/cataloger/package_url_test.go | 9 +++------ syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go | 11 ++++------- syft/pkg/rpmdb_metadata_test.go | 13 +++++-------- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/syft/pkg/cataloger/package_url_test.go b/syft/pkg/cataloger/package_url_test.go index c5c33c24f..61ae73f6f 100644 --- a/syft/pkg/cataloger/package_url_test.go +++ b/syft/pkg/cataloger/package_url_test.go @@ -91,7 +91,7 @@ func TestPackageURL(t *testing.T) { Metadata: pkg.RpmdbMetadata{ Name: "name", Version: "0.1.0", - Epoch: intRef(), + Epoch: nil, Arch: "amd64", Release: "3", }, @@ -131,9 +131,6 @@ func TestPackageURL(t *testing.T) { } } -func intRef(i ...int) *int { - if len(i) == 0 { - return nil - } - return &i[0] +func intRef(i int) *int { + return &i } diff --git a/syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go b/syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go index 9bab5a160..64c405cd4 100644 --- a/syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go +++ b/syft/pkg/cataloger/rpmdb/parse_rpmdb_test.go @@ -72,7 +72,7 @@ func TestParseRpmDB(t *testing.T) { MetadataType: pkg.RpmdbMetadataType, Metadata: pkg.RpmdbMetadata{ Name: "dive", - Epoch: intRef(), + Epoch: nil, Arch: "x86_64", Release: "1", Version: "0.9.2", @@ -99,7 +99,7 @@ func TestParseRpmDB(t *testing.T) { MetadataType: pkg.RpmdbMetadataType, Metadata: pkg.RpmdbMetadata{ Name: "dive", - Epoch: intRef(), + Epoch: nil, Arch: "x86_64", Release: "1", Version: "0.9.2", @@ -204,9 +204,6 @@ func TestToElVersion(t *testing.T) { } } -func intRef(i ...int) *int { - if len(i) == 0 { - return nil - } - return &i[0] +func intRef(i int) *int { + return &i } diff --git a/syft/pkg/rpmdb_metadata_test.go b/syft/pkg/rpmdb_metadata_test.go index 98fce0feb..7eded2046 100644 --- a/syft/pkg/rpmdb_metadata_test.go +++ b/syft/pkg/rpmdb_metadata_test.go @@ -10,13 +10,6 @@ import ( "github.com/sergi/go-diff/diffmatchpatch" ) -func intRef(i ...int) *int { - if len(i) == 0 { - return nil - } - return &i[0] -} - func TestRpmMetadata_pURL(t *testing.T) { tests := []struct { distro distro.Distro @@ -45,7 +38,7 @@ func TestRpmMetadata_pURL(t *testing.T) { Version: "v", Arch: "a", Release: "r", - Epoch: intRef(), + Epoch: nil, }, expected: "pkg:rpm/redhat/p@v-r?arch=a", }, @@ -104,3 +97,7 @@ func TestRpmMetadata_fileOwner(t *testing.T) { }) } } + +func intRef(i int) *int { + return &i +}