22 lines
436 B
Go
22 lines
436 B
Go
package user
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/assert"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetUserById(t *testing.T) {
|
|
r := gin.Default()
|
|
r.GET("/user/getUser", userApi.GetUserById)
|
|
|
|
req, _ := http.NewRequest("GET", "/user/getUser?id=123", nil)
|
|
w := httptest.NewRecorder()
|
|
r.ServeHTTP(w, req)
|
|
|
|
assert.Equal(t, http.StatusOK, w.Code)
|
|
t.Logf("Response: %s", w.Body.String())
|
|
}
|