From f4dec22c5097ba3d7635363b0a8d59766cb8aae6 Mon Sep 17 00:00:00 2001 From: cssivision Date: Tue, 28 Feb 2017 15:15:52 +0800 Subject: [PATCH] fix: buffer should reset when test logger output (#819) --- logger_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/logger_test.go b/logger_test.go index 6adf86bd..15d6ee9c 100644 --- a/logger_test.go +++ b/logger_test.go @@ -36,37 +36,43 @@ func TestLogger(t *testing.T) { // I wrote these first (extending the above) but then realized they are more // like integration tests because they test the whole logging process rather // than individual functions. Im not sure where these should go. - + buffer.Reset() performRequest(router, "POST", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "POST") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "PUT", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "PUT") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "DELETE", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "DELETE") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "PATCH", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "PATCH") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "HEAD", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "HEAD") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "OPTIONS", "/example") assert.Contains(t, buffer.String(), "200") assert.Contains(t, buffer.String(), "OPTIONS") assert.Contains(t, buffer.String(), "/example") + buffer.Reset() performRequest(router, "GET", "/notfound") assert.Contains(t, buffer.String(), "404") assert.Contains(t, buffer.String(), "GET") @@ -129,6 +135,7 @@ func TestSkippingPaths(t *testing.T) { performRequest(router, "GET", "/logged") assert.Contains(t, buffer.String(), "200") + buffer.Reset() performRequest(router, "GET", "/skipped") assert.Contains(t, buffer.String(), "") }