logger_test.go 881 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2014 Manu Martinez-Almeida. All rights reserved.
  2. // Use of this source code is governed by a MIT style
  3. // license that can be found in the LICENSE file.
  4. package gin
  5. import (
  6. "bytes"
  7. "testing"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. //TODO
  11. // func (engine *Engine) LoadHTMLGlob(pattern string) {
  12. // func (engine *Engine) LoadHTMLFiles(files ...string) {
  13. // func (engine *Engine) Run(addr string) error {
  14. // func (engine *Engine) RunTLS(addr string, cert string, key string) error {
  15. func init() {
  16. SetMode(TestMode)
  17. }
  18. func TestLogger(t *testing.T) {
  19. buffer := new(bytes.Buffer)
  20. router := New()
  21. router.Use(LoggerWithFile(buffer))
  22. router.GET("/example", func(c *Context) {})
  23. performRequest(router, "GET", "/example")
  24. assert.Contains(t, buffer.String(), "200")
  25. assert.Contains(t, buffer.String(), "GET")
  26. assert.Contains(t, buffer.String(), "/example")
  27. }