Skip to content
Myr

Make silent debug info on tests (#1765)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* make silent log on tests * fix coverage: check end-of-line at the end of debug msg

authored by Dmitry Kutakov · committed by 田欧 · parent a768f06 · Browse files · 5 files+27 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+27 added−19 removed

  • other:+27 added−19 removed

5 files+27 added−19 removed

modified:debug_test.go+1 added-1 removed
37 unmodified lines
38 debugPrint("DEBUG this!")39 SetMode(TestMode)40 debugPrint("DEBUG this!")41 SetMode(DebugMode)42 debugPrint("these are %d %s\n", 2, "error messages")42 debugPrint("these are %d %s", 2, "error messages")43 SetMode(TestMode)44 })45 assert.Equal(t, "[GIN-debug] these are 2 error messages\n", re)46}
107 unmodified lines
modified:deprecated_test.go+3 added-1 removed
22 unmodified lines
23 var obj struct {24 Foo string `form:"foo"`25 Bar string `form:"bar"`26 }27 captureOutput(t, func() {27 assert.NoError(t, c.BindWith(&obj, binding.Form))28 assert.NoError(t, c.BindWith(&obj, binding.Form))29 })30 assert.Equal(t, "foo", obj.Bar)31 assert.Equal(t, "bar", obj.Foo)32 assert.Equal(t, 0, w.Body.Len())33}
modified:gin_test.go+17 added-12 removed
25 unmodified lines
26}2728func setupHTMLFiles(t *testing.T, mode string, tls bool, loadMethod func(*Engine)) *httptest.Server {29 SetMode(mode)30 router := New()31 router.Delims("{[{", "}]}")32 router.SetFuncMap(template.FuncMap{33 "formatAsDate": formatAsDate,34 })35 loadMethod(router)36 router.GET("/test", func(c *Context) {37 c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})38 })39 router.GET("/raw", func(c *Context) {40 c.HTML(http.StatusOK, "raw.tmpl", map[string]interface{}{41 "now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),30 defer SetMode(TestMode)3132 var router *Engine33 captureOutput(t, func() {34 router = New()35 router.Delims("{[{", "}]}")36 router.SetFuncMap(template.FuncMap{37 "formatAsDate": formatAsDate,38 })39 loadMethod(router)40 router.GET("/test", func(c *Context) {41 c.HTML(http.StatusOK, "hello.tmpl", map[string]string{"name": "world"})42 })43 router.GET("/raw", func(c *Context) {44 c.HTML(http.StatusOK, "raw.tmpl", map[string]interface{}{45 "now": time.Date(2017, 07, 01, 0, 0, 0, 0, time.UTC),46 })47 })48 })4950 var ts *httptest.Server51
495 unmodified lines
modified:githubapi_test.go+5 added-5 removed
285 unmodified lines
286}287288func TestShouldBindUri(t *testing.T) {289 DefaultWriter = os.Stdout290 router := Default()290 router := New()291292 type Person struct {293 Name string `uri:"name" binding:"required"`294 Id string `uri:"id" binding:"required"`
13 unmodified lines
308}309310func TestBindUri(t *testing.T) {311 DefaultWriter = os.Stdout312 router := Default()312 router := New()313314 type Person struct {315 Name string `uri:"name" binding:"required"`316 Id string `uri:"id" binding:"required"`
13 unmodified lines
330}331332func TestBindUriError(t *testing.T) {333 DefaultWriter = os.Stdout334 router := Default()334 router := New()335336 type Member struct {337 Number string `uri:"num" binding:"required,uuid"`338 }
21 unmodified lines
360}361362func TestGithubAPI(t *testing.T) {363 DefaultWriter = os.Stdout364 router := Default()364 router := New()365 githubConfigRouter(router)366367 for _, route := range githubAPI {368 path, values := exampleFromPath(route.path)
66 unmodified lines
435}436437func BenchmarkParallelGithubDefault(b *testing.B) {438 DefaultWriter = os.Stdout439 router := Default()439 router := New()440 githubConfigRouter(router)441442 req, _ := http.NewRequest("POST", "/repos/manucorporat/sse/git/blobs", nil)443
8 unmodified lines
modified:recovery_test.go+1 added
41 unmodified lines
42 // TEST43 assert.Equal(t, http.StatusInternalServerError, w.Code)44 assert.Contains(t, buffer.String(), "GET /recovery")4546 SetMode(TestMode)47}4849// TestPanicWithAbort assert that panic has been recovered even if context.Abort was used.50func TestPanicWithAbort(t *testing.T) {
66 unmodified lines