forked from quic-go/quic-go
cleanup and improve tests of utils package
This commit is contained in:
57
utils/log_test.go
Normal file
57
utils/log_test.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Log", func() {
|
||||
var (
|
||||
b *bytes.Buffer
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
b = bytes.NewBuffer([]byte{})
|
||||
out = b
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
out = os.Stdout
|
||||
SetLogLevel(LogLevelNothing)
|
||||
})
|
||||
|
||||
It("log level nothing", func() {
|
||||
SetLogLevel(LogLevelNothing)
|
||||
Debugf("debug")
|
||||
Infof("info")
|
||||
Errorf("err")
|
||||
Expect(b.Bytes()).To(Equal([]byte("")))
|
||||
})
|
||||
|
||||
It("log level err", func() {
|
||||
SetLogLevel(LogLevelError)
|
||||
Debugf("debug")
|
||||
Infof("info")
|
||||
Errorf("err")
|
||||
Expect(b.Bytes()).To(Equal([]byte("err\n")))
|
||||
})
|
||||
|
||||
It("log level info", func() {
|
||||
SetLogLevel(LogLevelInfo)
|
||||
Debugf("debug")
|
||||
Infof("info")
|
||||
Errorf("err")
|
||||
Expect(b.Bytes()).To(Equal([]byte("info\nerr\n")))
|
||||
})
|
||||
|
||||
It("log level debug", func() {
|
||||
SetLogLevel(LogLevelDebug)
|
||||
Debugf("debug")
|
||||
Infof("info")
|
||||
Errorf("err")
|
||||
Expect(b.Bytes()).To(Equal([]byte("debug\ninfo\nerr\n")))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user