-
Notifications
You must be signed in to change notification settings - Fork 3
/
levels_test.go
62 lines (56 loc) · 1.74 KB
/
levels_test.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package logger
import (
"math"
"net/http"
"testing"
"github.com/getsentry/sentry-go"
"github.com/stretchr/testify/assert"
"go.uber.org/zap/zapcore"
)
func TestSentryLevel(t *testing.T) {
tests := []struct {
arg zapcore.Level
want sentry.Level
}{
{zapcore.DebugLevel, sentry.LevelDebug},
{zapcore.InfoLevel, sentry.LevelInfo},
{zapcore.WarnLevel, sentry.LevelWarning},
{zapcore.ErrorLevel, sentry.LevelError},
{zapcore.DPanicLevel, sentry.LevelError},
{zapcore.PanicLevel, sentry.LevelFatal},
{zapcore.FatalLevel, sentry.LevelFatal},
{zapcore.Level(math.MaxInt8), sentry.LevelDebug},
}
for _, tt := range tests {
//nolint:scopelint
t.Run(tt.arg.String(), func(t *testing.T) {
res := SentryLevel(tt.arg)
assert.Equal(t, tt.want, res, "SentryLevel() = %v, want %v", res, tt.want)
})
}
}
func TestSpanStatus(t *testing.T) {
tests := []struct {
arg int
want sentry.SpanStatus
}{
{http.StatusOK, sentry.SpanStatusOK},
{http.StatusBadRequest, sentry.SpanStatusInvalidArgument},
{http.StatusUnauthorized, sentry.SpanStatusUnauthenticated},
{http.StatusForbidden, sentry.SpanStatusPermissionDenied},
{http.StatusNotFound, sentry.SpanStatusNotFound},
{http.StatusConflict, sentry.SpanStatusAlreadyExists},
{499, sentry.SpanStatusCanceled},
{http.StatusInternalServerError, sentry.SpanStatusInternalError},
{http.StatusNotImplemented, sentry.SpanStatusUnimplemented},
{http.StatusServiceUnavailable, sentry.SpanStatusUnavailable},
{http.StatusGatewayTimeout, sentry.SpanStatusDeadlineExceeded},
}
for _, tt := range tests {
//nolint:scopelint
t.Run(http.StatusText(tt.arg), func(t *testing.T) {
res := SpanStatus(tt.arg)
assert.Equal(t, tt.want, res, "SentryLevel() = %v, want %v", res, tt.want)
})
}
}