From 1135764727f3dc525d0f674c784edbc81cc786f3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 6 Jun 2015 19:25:17 -0400 Subject: Initial commit. Install coinbase-go. * Use nut for vendored dependencies * Install coinbase-go to interact with the Coinbase API --- .../github.com/go-martini/martini/recovery_test.go | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 vendor/_nuts/github.com/go-martini/martini/recovery_test.go (limited to 'vendor/_nuts/github.com/go-martini/martini/recovery_test.go') diff --git a/vendor/_nuts/github.com/go-martini/martini/recovery_test.go b/vendor/_nuts/github.com/go-martini/martini/recovery_test.go new file mode 100644 index 0000000..17e2e01 --- /dev/null +++ b/vendor/_nuts/github.com/go-martini/martini/recovery_test.go @@ -0,0 +1,49 @@ +package martini + +import ( + "bytes" + "log" + "net/http" + "net/http/httptest" + "testing" +) + +func Test_Recovery(t *testing.T) { + buff := bytes.NewBufferString("") + recorder := httptest.NewRecorder() + + setENV(Dev) + m := New() + // replace log for testing + m.Map(log.New(buff, "[martini] ", 0)) + m.Use(func(res http.ResponseWriter, req *http.Request) { + res.Header().Set("Content-Type", "unpredictable") + }) + m.Use(Recovery()) + m.Use(func(res http.ResponseWriter, req *http.Request) { + panic("here is a panic!") + }) + m.ServeHTTP(recorder, (*http.Request)(nil)) + expect(t, recorder.Code, http.StatusInternalServerError) + expect(t, recorder.HeaderMap.Get("Content-Type"), "text/html") + refute(t, recorder.Body.Len(), 0) + refute(t, len(buff.String()), 0) +} + +func Test_Recovery_ResponseWriter(t *testing.T) { + recorder := httptest.NewRecorder() + recorder2 := httptest.NewRecorder() + + setENV(Dev) + m := New() + m.Use(Recovery()) + m.Use(func(c Context) { + c.MapTo(recorder2, (*http.ResponseWriter)(nil)) + panic("here is a panic!") + }) + m.ServeHTTP(recorder, (*http.Request)(nil)) + + expect(t, recorder2.Code, http.StatusInternalServerError) + expect(t, recorder2.HeaderMap.Get("Content-Type"), "text/html") + refute(t, recorder2.Body.Len(), 0) +} -- cgit v1.2.3