Skip to content

Commit

Permalink
distro/test_distro: remove New() in favor of DistroFactory()
Browse files Browse the repository at this point in the history
The New() function can be replaced by DistroFactory() in all places.
Let's delete it to be consistent with regular distros.

Introduce and export `TestDistro1Name` for convenience, because all
original callers of `New()` would have to construct the distro ID string
on their own.

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza committed Jan 9, 2024
1 parent ca72f7f commit e3a4622
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions pkg/distro/test_distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ const (
// release version.
TestDistroNameBase = "test_distro"

// An ID string for a Test Distro instance with release version 1.
TestDistro1Name = "test_distro-1"

TestArchName = "test_arch"
TestArch2Name = "test_arch2"
TestArch3Name = "test_arch3"
Expand Down Expand Up @@ -386,8 +389,3 @@ func DistroFactory(idStr string) distro.Distro {

return newTestDistro(fmt.Sprint(id.MajorVersion))
}

// New returns new instance of TestDistro named "test-distro-1".
func New() *TestDistro {
return newTestDistro("1")
}
10 changes: 5 additions & 5 deletions pkg/reporegistry/reporegistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func getTestingRepoRegistry() *RepoRegistry {
testDistro := test_distro.New()
testDistro := test_distro.DistroFactory(test_distro.TestDistro1Name)
return &RepoRegistry{
map[string]map[string][]rpmmd.RepoConfig{
testDistro.Name(): {
Expand Down Expand Up @@ -53,7 +53,7 @@ func getTestingRepoRegistry() *RepoRegistry {

func TestReposByImageType_reposByImageTypeName(t *testing.T) {
rr := getTestingRepoRegistry()
testDistro := test_distro.New()
testDistro := test_distro.DistroFactory(test_distro.TestDistro1Name)

ta, _ := testDistro.GetArch(test_distro.TestArchName)
ta2, _ := testDistro.GetArch(test_distro.TestArch2Name)
Expand Down Expand Up @@ -136,7 +136,7 @@ func TestInvalidReposByImageType(t *testing.T) {
// TestInvalidreposByImageTypeName tests return values from reposByImageTypeName
// for invalid distro name, arch and image type
func TestInvalidreposByImageTypeName(t *testing.T) {
testDistro := test_distro.New()
testDistro := test_distro.DistroFactory(test_distro.TestDistro1Name)
rr := getTestingRepoRegistry()

type args struct {
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestInvalidreposByImageTypeName(t *testing.T) {

func TestReposByArch(t *testing.T) {
rr := getTestingRepoRegistry()
testDistro := test_distro.New()
testDistro := test_distro.DistroFactory(test_distro.TestDistro1Name)

ta, _ := testDistro.GetArch(test_distro.TestArchName)
ta2, _ := testDistro.GetArch(test_distro.TestArch2Name)
Expand Down Expand Up @@ -313,7 +313,7 @@ func TestInvalidReposByArch(t *testing.T) {
// TestInvalidReposByArchName tests return values from ReposByArchName
// for invalid distro name and arch
func TestInvalidReposByArchName(t *testing.T) {
testDistro := test_distro.New()
testDistro := test_distro.DistroFactory(test_distro.TestDistro1Name)
rr := getTestingRepoRegistry()

type args struct {
Expand Down

0 comments on commit e3a4622

Please sign in to comment.