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:
authorJaime Martinez <jmartinez@gitlab.com>2020-02-03 18:58:19 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2020-02-03 18:58:19 +0300
commitf6bb22c68b2dfb5b5162335b6ffda813b79e8426 (patch)
treeb0083a3d6361f76327ffe3c9bd081fc213753853 /internal/testhelpers
parentf316fbf094402db2cf36c44639eeb3ae2f32c94b (diff)
use gorilla/handlers.ProxyHeaders to get the X-Forwarded-* headers and set them in the appropriate http.Request fields
Diffstat (limited to 'internal/testhelpers')
-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)
+ }
}