Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'internal/testhelpers/testhelpers.go')
-rw-r--r--internal/testhelpers/testhelpers.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/testhelpers/testhelpers.go b/internal/testhelpers/testhelpers.go
index c0b87d93..d703769b 100644
--- a/internal/testhelpers/testhelpers.go
+++ b/internal/testhelpers/testhelpers.go
@@ -7,6 +7,7 @@ import (
"net/url"
"testing"
+ "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
@@ -40,4 +41,19 @@ func AssertRedirectTo(t *testing.T, handler http.HandlerFunc, method string,
handler(recorder, req)
require.Equal(t, expectedURL, recorder.Header().Get("Location"))
+
+}
+
+// AssertLogContains checks that wantLogEntry is contained in at least one of the log entries
+func AssertLogContains(t *testing.T, wantLogEntry string, entries []*logrus.Entry) {
+ t.Helper()
+
+ if wantLogEntry != "" {
+ messages := make([]string, len(entries))
+ for k, entry := range entries {
+ messages[k] = entry.Message
+ }
+
+ require.Contains(t, messages, wantLogEntry)
+ }
}