| 1 | package logrus_testscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.13 bytes/" |
| 5 | "encoding/jsonscip-go gomod github.com/golang/go/src go1.13 `encoding/json`/" |
| 6 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 7 | |
| 8 | "github.com/sirupsen/logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/" |
| 9 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/" |
| 10 | ) |
| 11 | |
| 12 | func TestLevelJsonEncodingscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus_test`/TestLevelJsonEncoding().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 13 | type X struct { |
| 14 | Level logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level# |
| 15 | } |
| 16 | |
| 17 | var x X |
| 18 | x.Level = logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.WarnLevelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/WarnLevel. |
| 19 | var buf bytesscip-go gomod github.com/golang/go/src go1.13 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.13 bytes/Buffer# |
| 20 | enc := jsonscip-go gomod github.com/golang/go/src go1.13 `encoding/json`/.NewEncoderscip-go gomod github.com/golang/go/src go1.13 `encoding/json`/NewEncoder().(&buf) |
| 21 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NoError().(t, enc.Encodescip-go gomod github.com/golang/go/src go1.13 `encoding/json`/Encoder#Encode().(x)) |
| 22 | dec := jsonscip-go gomod github.com/golang/go/src go1.13 `encoding/json`/.NewDecoderscip-go gomod github.com/golang/go/src go1.13 `encoding/json`/NewDecoder().(&buf) |
| 23 | var y X |
| 24 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NoError().(t, dec.Decodescip-go gomod github.com/golang/go/src go1.13 `encoding/json`/Decoder#Decode().(&y)) |
| 25 | } |
| 26 | |
| 27 | func TestLevelUnmarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus_test`/TestLevelUnmarshalText().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 28 | var u logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level# |
| 29 | for _, level := range logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.AllLevelsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/AllLevels. { |
| 30 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(level.Stringscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#String().(), func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 31 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NoError().(t, u.UnmarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#UnmarshalText().([]byte(level.Stringscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#String().()))) |
| 32 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, level, u) |
| 33 | }) |
| 34 | } |
| 35 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().("invalid", func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 36 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Error().(t, u.UnmarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#UnmarshalText().([]byte("invalid"))) |
| 37 | }) |
| 38 | } |
| 39 | |
| 40 | func TestLevelMarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus_test`/TestLevelMarshalText().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 41 | levelStrings := []string{ |
| 42 | "panic", |
| 43 | "fatal", |
| 44 | "error", |
| 45 | "warning", |
| 46 | "info", |
| 47 | "debug", |
| 48 | "trace", |
| 49 | } |
| 50 | for idx, val := range logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.AllLevelsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/AllLevels. { |
| 51 | level := val |
| 52 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(level.Stringscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#String().(), func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 53 | var cmp logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/.Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level# |
| 54 | b, err := level.MarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#MarshalText().() |
| 55 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 56 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, levelStrings[idx], string(b)) |
| 57 | err = cmp.UnmarshalTextscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#UnmarshalText().(b) |
| 58 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 59 | requirescip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/require`/Equal().(t, level, cmp) |
| 60 | }) |
| 61 | } |
| 62 | } |