distroregistry/test: make the List test generic

So we don't need to update the list when we changed the supported distros.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2021-03-11 13:26:39 +01:00 committed by Ondřej Budai
parent e4295dc49c
commit 9bc35d5e98

View file

@ -1,29 +1,21 @@
package distroregistry_test
package distroregistry
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
"github.com/osbuild/osbuild-composer/internal/distro/fedora33"
"github.com/osbuild/osbuild-composer/internal/distro/rhel8"
"github.com/osbuild/osbuild-composer/internal/distro/rhel84"
"github.com/osbuild/osbuild-composer/internal/distroregistry"
)
// Test that all distros are registered properly and that Registry.List() works.
func TestRegistry_List(t *testing.T) {
expected := []string{
"centos-8",
"fedora-32",
"fedora-33",
"rhel-8",
"rhel-84",
// build expected distros
var expected []string
for _, distroInitializer := range supportedDistros {
d := distroInitializer()
expected = append(expected, d.Name())
}
distros, err := distroregistry.New(fedora32.New(), fedora33.New(), rhel8.New(), rhel84.New(), rhel84.NewCentos())
require.NoError(t, err)
distros := NewDefault()
require.ElementsMatch(t, expected, distros.List(), "unexpected list of distros")
}