health-go/test/service/service_test.go

21 lines
355 B
Go
Raw Permalink Normal View History

2024-11-14 01:15:55 +08:00
package service
2024-11-03 01:32:51 +08:00
import (
2024-11-14 01:15:55 +08:00
"health-go/router"
2024-11-03 01:32:51 +08:00
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPingRoute(t *testing.T) {
2024-11-14 01:15:55 +08:00
r := router.SetupRouter()
2024-11-03 01:32:51 +08:00
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/fetchHosList", nil)
2024-11-14 01:15:55 +08:00
r.ServeHTTP(w, req)
2024-11-03 01:32:51 +08:00
assert.JSONEq(t, `{"code: 20"}`, w.Body.String())
}