2022-05-13 13:26:45 -04:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2022-06-23 16:13:58 -04:00
|
|
|
"github.com/datarhei/core/v16/http/api"
|
|
|
|
|
"github.com/datarhei/core/v16/http/mock"
|
2022-05-13 13:26:45 -04:00
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func getDummyLogRouter() *echo.Echo {
|
|
|
|
|
router := mock.DummyEcho()
|
|
|
|
|
|
|
|
|
|
handler := NewLog(nil)
|
|
|
|
|
|
|
|
|
|
router.Add("GET", "/", handler.Log)
|
|
|
|
|
|
|
|
|
|
return router
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestLog(t *testing.T) {
|
|
|
|
|
router := getDummyLogRouter()
|
|
|
|
|
|
|
|
|
|
response := mock.Request(t, http.StatusOK, router, "GET", "/", nil)
|
|
|
|
|
|
|
|
|
|
mock.Validate(t, []api.LogEvent{}, response.Data)
|
|
|
|
|
}
|