From 53c4797606e5ded3ddc1437ca164d0c60fc74a12 Mon Sep 17 00:00:00 2001 From: Karthic Rao Date: Tue, 11 Aug 2015 22:02:13 +0530 Subject: [PATCH] Initial setup of test for recorder.go of middleware package --- middleware/recorder_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 middleware/recorder_test.go diff --git a/middleware/recorder_test.go b/middleware/recorder_test.go new file mode 100644 index 00000000..5a2fa10c --- /dev/null +++ b/middleware/recorder_test.go @@ -0,0 +1,19 @@ +package middleware + +import ( + "net/http" + "net/http/httptest" + "reflect" + "testing" +) + +func TestNewResponseRecorder(t *testing.T) { + w := httptest.NewRecorder() + recordRequest := NewResponseRecorder(w) + if !reflect.DeepEqual(recordRequest.ResponseWriter, w) { + t.Fatalf("Expected Response writer in the Recording to be same as the one sent") + } + if recordRequest.status != http.StatusOK { + t.Fatalf("Expected recorded status to be http.StatusOK") + } +}