Explorar o código

debugPrintRoutes() unit test

Manu Mtz-Almeida %!s(int64=10) %!d(string=hai) anos
pai
achega
fd5d4294a5
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      debug_test.go

+ 9 - 0
debug_test.go

@@ -57,6 +57,15 @@ func TestDebugPrintError(t *testing.T) {
 	assert.Equal(t, w.String(), "[GIN-debug] [ERROR] this is an error\n")
 	assert.Equal(t, w.String(), "[GIN-debug] [ERROR] this is an error\n")
 }
 }
 
 
+func TestDebugPrintRoutes(t *testing.T) {
+	var w bytes.Buffer
+	setup(&w)
+	defer teardown()
+
+	debugPrintRoute("GET", "/path/to/route/:param", HandlersChain{func(c *Context) {}, handlerNameTest})
+	assert.Equal(t, w.String(), "[GIN-debug] GET   /path/to/route/:param     --> github.com/gin-gonic/gin.handlerNameTest (2 handlers)\n")
+}
+
 func setup(w io.Writer) {
 func setup(w io.Writer) {
 	SetMode(DebugMode)
 	SetMode(DebugMode)
 	log.SetOutput(w)
 	log.SetOutput(w)