-
Notifications
You must be signed in to change notification settings - Fork 444
/
logging.go
32 lines (27 loc) · 915 Bytes
/
logging.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package assertions
import (
"fmt"
"net/http"
"github.com/solo-io/gloo/test/testutils"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
"github.com/solo-io/gloo/test/gomega/matchers"
"github.com/solo-io/go-utils/stats"
"go.uber.org/zap/zapcore"
)
// LogLevelAssertion returns an Assertion to verify that the dynamic log level matches the provided value
func LogLevelAssertion(logLevel zapcore.Level) types.AsyncAssertion {
loggingRequest := testutils.DefaultRequestBuilder().
WithPort(stats.DefaultPort).
WithPath("logging").
Build()
return Eventually(func(g Gomega) {
resp, err := http.DefaultClient.Do(loggingRequest)
g.Expect(err).NotTo(HaveOccurred())
defer resp.Body.Close()
g.Expect(resp).Should(matchers.HaveHttpResponse(&matchers.HttpResponse{
StatusCode: http.StatusOK,
Body: fmt.Sprintf("{\"level\":\"%s\"}\n", logLevel.String()),
}))
}, "5s", ".1s")
}