Switch LogOf from panicking when logger is missing to creating logger with the defaults.

Update CORS tests to a table-based test and cover more cases.
This commit is contained in:
Jessica Forrester
2014-09-09 17:05:18 -04:00
parent becf6ca4e7
commit 0cac1c5f79
7 changed files with 85 additions and 92 deletions

View File

@@ -91,19 +91,12 @@ func TestLogOf(t *testing.T) {
t.Errorf("Unexpected error: %v", err)
}
handler := func(w http.ResponseWriter, r *http.Request) {
var want *respLogger
if makeLogger {
want = NewLogged(req, &w)
} else {
defer func() {
if r := recover(); r == nil {
t.Errorf("Expected LogOf to panic")
}
}()
NewLogged(req, &w)
}
got := LogOf(w)
if want != got {
t.Errorf("Expected %v, got %v", want, got)
got := reflect.TypeOf(*LogOf(r, w)).String()
if got != "httplog.respLogger" {
t.Errorf("Expected %v, got %v", "httplog.respLogger", got)
}
}
w := httptest.NewRecorder()