From d7b0323a2dec205b7a41bd9b4c5d7e30982fc44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Thu, 11 Mar 2021 13:33:51 +0100 Subject: [PATCH] distroregistry/test: add test for GetDistro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding the sweet coverage. Signed-off-by: Ondřej Budai --- internal/distroregistry/distroregistry_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/internal/distroregistry/distroregistry_test.go b/internal/distroregistry/distroregistry_test.go index c38985f26..ebe6a8665 100644 --- a/internal/distroregistry/distroregistry_test.go +++ b/internal/distroregistry/distroregistry_test.go @@ -4,6 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" + + "github.com/osbuild/osbuild-composer/internal/distro/rhel8" ) // Test that all distros are registered properly and that Registry.List() works. @@ -19,3 +21,16 @@ func TestRegistry_List(t *testing.T) { require.ElementsMatch(t, expected, distros.List(), "unexpected list of distros") } + +func TestRegistry_GetDistro(t *testing.T) { + distros := NewDefault() + + t.Run("distro exists", func(t *testing.T) { + expectedDistro := rhel8.New() + require.Equal(t, expectedDistro.Name(), distros.GetDistro(expectedDistro.Name()).Name()) + }) + + t.Run("distro doesn't exist", func(t *testing.T) { + require.Nil(t, distros.GetDistro("toucan-os")) + }) +}