1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package example
import (
"net/http"
"testing"
"github.com/appleboy/gofight/v2"
"github.com/stretchr/testify/assert"
)
func TestGinHelloWorld(t *testing.T) {
r := gofight.New()
r.GET("/").
SetDebug(true).
Run(GinEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, "Hello World", r.Body.String())
assert.Equal(t, http.StatusOK, r.Code)
})
}
func TestGinHelloHandler(t *testing.T) {
r := gofight.New()
r.GET("/user/appleboy").
SetDebug(true).
Run(GinEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, "Hello, appleboy", r.Body.String())
assert.Equal(t, http.StatusOK, r.Code)
})
}
|