-
Notifications
You must be signed in to change notification settings - Fork 395
Expand file tree
/
Copy pathlogger_test.go
More file actions
31 lines (27 loc) · 769 Bytes
/
logger_test.go
File metadata and controls
31 lines (27 loc) · 769 Bytes
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
package req
import (
"bytes"
"log"
"testing"
"github.com/imroc/req/v3/internal/tests"
)
func TestLogger(t *testing.T) {
buf := new(bytes.Buffer)
l := NewLogger(buf, "", log.Ldate|log.Lmicroseconds)
c := tc().SetLogger(l)
c.SetProxyURL(":=\\<>ksfj&*&sf")
tests.AssertContains(t, buf.String(), "error", true)
buf.Reset()
c.R().SetOutput(nil)
tests.AssertContains(t, buf.String(), "warn", true)
}
func TestLoggerFromStandardLogger(t *testing.T) {
buf := new(bytes.Buffer)
l := NewLoggerFromStandardLogger(log.New(buf, "", log.Ldate|log.Lmicroseconds))
c := tc().SetLogger(l)
c.SetProxyURL(":=\\<>ksfj&*&sf")
tests.AssertContains(t, buf.String(), "error", true)
buf.Reset()
c.R().SetOutput(nil)
tests.AssertContains(t, buf.String(), "warn", true)
}