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
Provenance
- Commit
31bbb10- Tree
5a99d6d- Author
Dmitry Kutakov <vkd.castle@gmail.com>- Committer
田欧 <thinkerou@gmail.com>- Parent
a768f06
5 files changed+27 added−19 removed
modified:debug_test.go+1 added-1 removed
37 unmodified lines38 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 linesmodified:deprecated_test.go+3 added-1 removed
22 unmodified lines23 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 lines26 }27 28 func 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)31+32+ 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 })49 50 var ts *httptest.Server51 495 unmodified linesmodified:githubapi_test.go+5 added-5 removed
285 unmodified lines286 }287 288 func TestShouldBindUri(t *testing.T) {289 DefaultWriter = os.Stdout290- router := Default()290+ router := New()291 292 type Person struct {293 Name string `uri:"name" binding:"required"`294 Id string `uri:"id" binding:"required"`13 unmodified lines308 }309 310 func TestBindUri(t *testing.T) {311 DefaultWriter = os.Stdout312- router := Default()312+ router := New()313 314 type Person struct {315 Name string `uri:"name" binding:"required"`316 Id string `uri:"id" binding:"required"`13 unmodified lines330 }331 332 func TestBindUriError(t *testing.T) {333 DefaultWriter = os.Stdout334- router := Default()334+ router := New()335 336 type Member struct {337 Number string `uri:"num" binding:"required,uuid"`338 }21 unmodified lines360 }361 362 func TestGithubAPI(t *testing.T) {363 DefaultWriter = os.Stdout364- router := Default()364+ router := New()365 githubConfigRouter(router)366 367 for _, route := range githubAPI {368 path, values := exampleFromPath(route.path)66 unmodified lines435 }436 437 func BenchmarkParallelGithubDefault(b *testing.B) {438 DefaultWriter = os.Stdout439- router := Default()439+ router := New()440 githubConfigRouter(router)441 442 req, _ := http.NewRequest("POST", "/repos/manucorporat/sse/git/blobs", nil)443 8 unmodified linesmodified:recovery_test.go+1 added
41 unmodified lines42 // TEST43 assert.Equal(t, http.StatusInternalServerError, w.Code)44 assert.Contains(t, buffer.String(), "GET /recovery")45 46+ SetMode(TestMode)47 }48 49 // TestPanicWithAbort assert that panic has been recovered even if context.Abort was used.50 func TestPanicWithAbort(t *testing.T) {66 unmodified lines