diff --git a/pkg/reporegistry/repository_test.go b/pkg/reporegistry/repository_test.go index ad24e9c9d6..0bcf75f63f 100644 --- a/pkg/reporegistry/repository_test.go +++ b/pkg/reporegistry/repository_test.go @@ -1,14 +1,20 @@ package reporegistry import ( + "fmt" "path/filepath" "reflect" + "slices" "testing" + "github.com/sirupsen/logrus" + logrusTest "github.com/sirupsen/logrus/hooks/test" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/osbuild/images/internal/common" "github.com/osbuild/images/pkg/distro/test_distro" "github.com/osbuild/images/pkg/rpmmd" - "github.com/stretchr/testify/assert" ) func getConfPaths(t *testing.T) []string { @@ -295,3 +301,16 @@ func Test_LoadAllRepositories(t *testing.T) { }) } } + +func TestLoadRepositoriesLogging(t *testing.T) { + _, logHook := logrusTest.NewNullLogger() + logrus.AddHook(logHook) + + confPaths := getConfPaths(t) + _, err := LoadAllRepositories(confPaths) + require.NoError(t, err) + needle := "Loaded repository configuration file: rhel-8.10.json" + assert.True(t, slices.ContainsFunc(logHook.AllEntries(), func(entry *logrus.Entry) bool { + return needle == entry.Message + }), fmt.Sprintf("%q not found in look entries %+v (last: %q)", needle, logHook.AllEntries(), logHook.LastEntry().Message)) +}