added support for string type
[govpp.git] / vendor / github.com / sirupsen / logrus / hooks / test / test_test.go
1 package test
2
3 import (
4         "testing"
5
6         "github.com/sirupsen/logrus"
7         "github.com/stretchr/testify/assert"
8 )
9
10 func TestAllHooks(t *testing.T) {
11
12         assert := assert.New(t)
13
14         logger, hook := NewNullLogger()
15         assert.Nil(hook.LastEntry())
16         assert.Equal(0, len(hook.Entries))
17
18         logger.Error("Hello error")
19         assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
20         assert.Equal("Hello error", hook.LastEntry().Message)
21         assert.Equal(1, len(hook.Entries))
22
23         logger.Warn("Hello warning")
24         assert.Equal(logrus.WarnLevel, hook.LastEntry().Level)
25         assert.Equal("Hello warning", hook.LastEntry().Message)
26         assert.Equal(2, len(hook.Entries))
27
28         hook.Reset()
29         assert.Nil(hook.LastEntry())
30         assert.Equal(0, len(hook.Entries))
31
32         hook = NewGlobal()
33
34         logrus.Error("Hello error")
35         assert.Equal(logrus.ErrorLevel, hook.LastEntry().Level)
36         assert.Equal("Hello error", hook.LastEntry().Message)
37         assert.Equal(1, len(hook.Entries))
38
39 }