test: add gin test sample

This commit is contained in:
2024-11-03 01:32:51 +08:00
parent da0b0085c9
commit c219d81b89
3 changed files with 32 additions and 3 deletions

View File

@ -0,0 +1,20 @@
package services
import (
"health-go/routers"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPingRoute(t *testing.T) {
router := routers.SetupRouter()
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/fetchHosList", nil)
router.ServeHTTP(w, req)
assert.JSONEq(t, `{"code: 20"}`, w.Body.String())
}