12func TestLoggingHandler_ServeHTTP(t *testing.T) {
17 ExpectedLogMessage string
19 {defaultRequestLoggingFormat, fmt.Sprintf("127.0.0.1 - - [%s] test-server GET - \"/foo/bar\" HTTP/1.1 \"\" 200 4 0.000\n", ts.Format("02/Jan/2006:15:04:05 -0700"))},
20 {"{{.RequestMethod}}", "GET\n"},
23 for _, test := range tests {
24 buf := bytes.NewBuffer(nil)
25 handler := func(w http.ResponseWriter, req *http.Request) {
26 w.Write([]byte("test"))
29 h := LoggingHandler(buf, http.HandlerFunc(handler), true, test.Format)
31 r, _ := http.NewRequest("GET", "/foo/bar", nil)
32 r.RemoteAddr = "127.0.0.1"
33 r.Host = "test-server"
35 h.ServeHTTP(httptest.NewRecorder(), r)
37 actual := buf.String()
38 if actual != test.ExpectedLogMessage {
39 t.Errorf("Log message was\n%s\ninstead of expected \n%s", actual, test.ExpectedLogMessage)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list