debug_test.go 861 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestIsDebugging(t *testing.T) {
  10. SetMode(DebugMode)
  11. assert.True(t, IsDebugging())
  12. SetMode(ReleaseMode)
  13. assert.False(t, IsDebugging())
  14. SetMode(TestMode)
  15. assert.False(t, IsDebugging())
  16. }
  17. // TODO
  18. // func TestDebugPrint(t *testing.T) {
  19. // buffer := bytes.NewBufferString("")
  20. // debugLogger.
  21. // log.SetOutput(buffer)
  22. // SetMode(ReleaseMode)
  23. // debugPrint("This is a example")
  24. // assert.Equal(t, buffer.Len(), 0)
  25. // SetMode(DebugMode)
  26. // debugPrint("This is %s", "a example")
  27. // assert.Equal(t, buffer.String(), "[GIN-debug] This is a example")
  28. // SetMode(TestMode)
  29. // log.SetOutput(os.Stdout)
  30. // }